A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 叶子哥 中级黑马   /  2016-6-12 12:30  /  2004 人查看  /  3 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文


     先看效果:



主要代码如下:
  1. @implementation ViewController

  2. - (IBAction)loadingBtn:(UIButton *)sender {
  3.    
  4.     [self.view endEditing:YES];
  5.     NSString *QQNumber = self.qqNumber.text;
  6.     NSString *QQPwd = self.pwd.text;
  7.     NSLog(@"用户QQ号码是:%@, 密码:%@",QQNumber,QQPwd);
  8.    
  9.     if ([QQNumber isEqualToString:@"123456"] && [QQPwd isEqualToString:@"qwert"]) {
  10.         sender.hidden = YES;
  11.         self.act.hidden = NO;
  12.         self.showLoadLabel.hidden = NO;
  13.         [self.act startAnimating];
  14.         
  15.         dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
  16.             [self showLoadedSuccess];
  17.             
  18.         });

  19.     }else{
  20.    
  21.         //创建弹框
  22.         UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"密码或账号不正确" preferredStyle:UIAlertControllerStyleAlert];
  23.         self.alert = alert;
  24.         //给弹框添加按钮
  25.         UIAlertAction *alertAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
  26.             NSLog(@"点击了");
  27.         }];
  28.         [alert addAction:alertAction];
  29.         
  30.         //显示弹框
  31.         [self presentViewController:alert animated:YES completion:^{
  32.             NSLog(@"点击了");
  33.         }];

  34.     }
  35.    
  36.    
  37. }

  38. - (void)showLoadedSuccess{

  39.     [self.act stopAnimating];
  40.     [self.showLoadLabel setText:@"登入成功"];
  41.     self.act.hidden = YES;
  42. }

  43. - (void)viewDidLoad {
  44.     [super viewDidLoad];
  45.     // Do any additional setup after loading the view, typically from a nib.
  46.    
  47.     self.act.hidden = YES;
  48.     self.showLoadLabel.hidden = YES;
  49. }
复制代码


3 个回复

倒序浏览
楼主棒棒哒
回复 使用道具 举报
楼主,为什么没有下拉菜单选择用户呢
回复 使用道具 举报
东西是好东西,希望再接再厉
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马