码迷,mamicode.com
首页 > 其他好文 > 详细

iPad开发--QQ空间布局,登录模块

时间:2016-06-06 11:48:15      阅读:236      评论:0      收藏:0      [点我收藏+]

标签:

一.登录模块

  • 登录逻辑
     1 - (IBAction)loginClick:(UIButton *)sender {
     2     
     3     self.view.userInteractionEnabled = NO;
     4     
     5     [self.view endEditing:YES];
     6     
     7     [self.activeView startAnimating];
     8     
     9     if (self.accountField.text.length == 0 || self.pwdField.text.length == 0) {
    10         
    11         [self showError:@"帐号和密码不能为空"];
    12     }
    13     if ([self.accountField.text isEqualToString:@"123"] && [self.pwdField.text isEqualToString:@"123"]) {
    14         
    15         // 帐号密码正确 跳转控制器
    16         ChaosMainViewController *mainVC = [[ChaosMainViewController alloc] init];
    17         mainVC.view.backgroundColor = [UIColor colorWithRed:55 / 255.0 green:55 / 255.0 blue:55 / 255.0 alpha:1.0];
    18         [self presentViewController:mainVC animated:YES completion:nil];
    19         
    20     } else {
    21         
    22         [self showError:@"帐号或密码错误"];
    23     }
    24     
    25 }

     

  • 登录不成功后的动画效果
     1 - (void)showError:(NSString *)error
     2 {
     3     dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
     4         
     5         UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"登录错误" message:error preferredStyle:UIAlertControllerStyleAlert];
     6         [alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
     7             
     8         }]];
     9         
    10         [self presentViewController:alert animated:YES completion:nil];
    11         
    12         CAKeyframeAnimation *shakeAnim = [CAKeyframeAnimation animationWithKeyPath:@"transform.translation.x"];
    13         shakeAnim.values = @[@-10,@0,@10,@0];
    14         shakeAnim.repeatCount = 9;
    15         shakeAnim.repeatDuration = 0.3;
    16         // 动画
    17         [self.animView.layer addAnimation:shakeAnim forKey:nil];
    18         
    19         [self.activeView stopAnimating];
    20         
    21         self.view.userInteractionEnabled = YES;
    22     });
    23     
    24 }

     

  • 记住密码和自动登录逻辑                                                                                                  技术分享

iPad开发--QQ空间布局,登录模块

标签:

原文地址:http://www.cnblogs.com/gchlcc/p/5562963.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!