Commit d5b843aa489a807fd5e905a77e151fca49eb3513

Authored by zhangxiaowen
1 parent 54b891bb

no message

CNLiveQrCodeModule/Classes/Controller/CNLiveMyQrCodeController.m
... ... @@ -153,14 +153,6 @@ static const CGFloat timeValue = 1.5;
153 153  
154 154 }
155 155  
156   -//- (void)navigationBar:(CNLiveQrCodeNavigationBar *)navigationBar actionEvents:(NSString *)actionEvents{
157   -// if ([actionEvents isEqualToString:@"1"]) {
158   -// [self goBack];
159   -// }
160   -// else if ([actionEvents isEqualToString:@"2"]){
161   -//
162   -// }
163   -//}
164 156 - (void)didHideAlertController:(QMUIAlertController *)alertController{
165 157 self.navigationBar.right.userInteractionEnabled = YES;
166 158  
... ... @@ -205,69 +197,76 @@ static const CGFloat timeValue = 1.5;
205 197 [strongSelf goBack];
206 198 };
207 199 _navigationBar.onClickRightButton = ^{
208   - self.navigationBar.right.userInteractionEnabled = NO;
209   - __weak typeof(self) weakSelf = self;
210   - QMUIAlertAction *action1 = [QMUIAlertAction actionWithTitle:@"保存图片" style:QMUIAlertActionStyleDefault handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) {
211   - __strong typeof(weakSelf) strongSelf = weakSelf;
212   - if(!strongSelf) return ;
213   - [strongSelf getPHAuthorizationStatus:^{
214   - UIImage *image = [strongSelf generateImage:strongSelf.qrCodeView];
215   - [QMUITips showLoadingInView:strongSelf.view];
216   - [strongSelf saveImage:image];
217   - [QMUITips hideAllTipsInView:strongSelf.view];
218   - }];
219   - self.navigationBar.right.userInteractionEnabled = YES;
  200 + __strong typeof(weakSelf) strongSelf = weakSelf;
  201 + if(!strongSelf) return ;
  202 + [strongSelf rightButton];
  203 +
  204 + };
  205 + }
  206 + return _navigationBar;
  207 +}
220 208  
221   - }];
222   - QMUIAlertAction *action2 = [QMUIAlertAction actionWithTitle:@"扫描二维码" style:QMUIAlertActionStyleDefault handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) {
223   - __strong typeof(weakSelf) strongSelf = weakSelf;
224   - if(!strongSelf) return ;
225   - if(strongSelf.isScanCode){
226   - [strongSelf.navigationController popViewControllerAnimated:YES];
227   - }else{
228   - CNLiveScanQrCodeController *vc = [[CNLiveScanQrCodeController alloc]init];
229   - vc.isMyCode = YES;
230   - [strongSelf.navigationController pushViewController:vc animated:YES];
231   - }
232   - self.navigationBar.right.userInteractionEnabled = YES;
233   - }];
234   - QMUIAlertAction *action3 = [QMUIAlertAction actionWithTitle:@"重置二维码" style:QMUIAlertActionStyleDefault handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) {
235   - __strong typeof(weakSelf) strongSelf = weakSelf;
236   - if(!strongSelf) return ;
237   - [strongSelf.qrCodeView generateQRCode:@"reset"];
238   - self.navigationBar.right.userInteractionEnabled = YES;
  209 +- (void)rightButton{
  210 + self.navigationBar.right.userInteractionEnabled = NO;
  211 + __weak typeof(self) weakSelf = self;
  212 + QMUIAlertAction *action1 = [QMUIAlertAction actionWithTitle:@"保存图片" style:QMUIAlertActionStyleDefault handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) {
  213 + __strong typeof(weakSelf) strongSelf = weakSelf;
  214 + if(!strongSelf) return ;
  215 + [strongSelf getPHAuthorizationStatus:^{
  216 + UIImage *image = [strongSelf generateImage:strongSelf.qrCodeView];
  217 + [QMUITips showLoadingInView:strongSelf.view];
  218 + [strongSelf saveImage:image];
  219 + [QMUITips hideAllTipsInView:strongSelf.view];
  220 + }];
  221 + strongSelf.navigationBar.right.userInteractionEnabled = YES;
239 222  
240   - }];
241   - QMUIAlertAction *cancel = [QMUIAlertAction actionWithTitle:@"取消" style:QMUIAlertActionStyleCancel handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) {
242   - __strong typeof(weakSelf) strongSelf = weakSelf;
243   - if(!strongSelf) return ;
244   - self.navigationBar.right.userInteractionEnabled = YES;
  223 + }];
  224 + QMUIAlertAction *action2 = [QMUIAlertAction actionWithTitle:@"扫描二维码" style:QMUIAlertActionStyleDefault handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) {
  225 + __strong typeof(weakSelf) strongSelf = weakSelf;
  226 + if(!strongSelf) return ;
  227 + if(strongSelf.isScanCode){
  228 + [strongSelf.navigationController popViewControllerAnimated:YES];
  229 + }else{
  230 + CNLiveScanQrCodeController *vc = [[CNLiveScanQrCodeController alloc]init];
  231 + vc.isMyCode = YES;
  232 + [strongSelf.navigationController pushViewController:vc animated:YES];
  233 + }
  234 + strongSelf.navigationBar.right.userInteractionEnabled = YES;
  235 + }];
  236 + QMUIAlertAction *action3 = [QMUIAlertAction actionWithTitle:@"重置二维码" style:QMUIAlertActionStyleDefault handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) {
  237 + __strong typeof(weakSelf) strongSelf = weakSelf;
  238 + if(!strongSelf) return ;
  239 + [strongSelf.qrCodeView generateQRCode:@"reset"];
  240 + strongSelf.navigationBar.right.userInteractionEnabled = YES;
  241 +
  242 + }];
  243 + QMUIAlertAction *cancel = [QMUIAlertAction actionWithTitle:@"取消" style:QMUIAlertActionStyleCancel handler:^(__kindof QMUIAlertController *aAlertController, QMUIAlertAction *action) {
  244 + __strong typeof(weakSelf) strongSelf = weakSelf;
  245 + if(!strongSelf) return ;
  246 + strongSelf.navigationBar.right.userInteractionEnabled = YES;
245 247  
246   - }];
247   -
248   - QMUIAlertController *alertController = [QMUIAlertController alertControllerWithTitle:@"" message:@"" preferredStyle:QMUIAlertControllerStyleActionSheet];
249   - alertController.delegate = self;
250   - [alertController addAction:action1];
251   - [alertController addAction:action2];
252   - [alertController addAction:action3];
253   - [alertController addAction:cancel];
  248 + }];
  249 +
  250 + QMUIAlertController *alertController = [QMUIAlertController alertControllerWithTitle:@"" message:@"" preferredStyle:QMUIAlertControllerStyleActionSheet];
  251 + alertController.delegate = self;
  252 + [alertController addAction:action1];
  253 + [alertController addAction:action2];
  254 + [alertController addAction:action3];
  255 + [alertController addAction:cancel];
254 256  
255   - NSMutableDictionary *titleAttributs = [[NSMutableDictionary alloc] initWithDictionary:alertController.alertTitleAttributes];
256   -
257   - titleAttributs[NSForegroundColorAttributeName] = [UIColor colorWithRed:35/255.0 green:212/255.0 blue:30/255.0 alpha:1.0];
258   -
259   - NSMutableDictionary *cancelAttributs = [[NSMutableDictionary alloc] initWithDictionary:alertController.alertTitleAttributes];
260   - cancelAttributs[NSForegroundColorAttributeName] = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0];
  257 + NSMutableDictionary *titleAttributs = [[NSMutableDictionary alloc] initWithDictionary:alertController.alertTitleAttributes];
  258 +
  259 + titleAttributs[NSForegroundColorAttributeName] = [UIColor colorWithRed:35/255.0 green:212/255.0 blue:30/255.0 alpha:1.0];
  260 +
  261 + NSMutableDictionary *cancelAttributs = [[NSMutableDictionary alloc] initWithDictionary:alertController.alertTitleAttributes];
  262 + cancelAttributs[NSForegroundColorAttributeName] = [UIColor colorWithRed:51/255.0 green:51/255.0 blue:51/255.0 alpha:1.0];
261 263  
262   - action1.buttonAttributes = titleAttributs;
263   - action2.buttonAttributes = titleAttributs;
264   - action3.buttonAttributes = titleAttributs;
265   - cancel.buttonAttributes = cancelAttributs;
  264 + action1.buttonAttributes = titleAttributs;
  265 + action2.buttonAttributes = titleAttributs;
  266 + action3.buttonAttributes = titleAttributs;
  267 + cancel.buttonAttributes = cancelAttributs;
266 268  
267   - [alertController showWithAnimated:YES];
268   - };
269   - }
270   - return _navigationBar;
  269 + [alertController showWithAnimated:YES];
271 270 }
272 271  
273 272 @end
... ...
Example/CNLiveQrCodeModule/CNLIVEAppDelegate.m
... ... @@ -63,7 +63,7 @@
63 63 }];
64 64 self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
65 65  
66   - CNLiveGroupQrCodeController *vc = [[CNLiveGroupQrCodeController alloc] init];
  66 + CNLiveScanQrCodeController *vc = [[CNLiveScanQrCodeController alloc] init];
67 67 // vc.ID = @"http://www.baidu.com";
68 68 UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:vc];
69 69  
... ...