iOS9 警告框

來源:互聯網
上載者:User

標籤:

iOS9中警告框的使用。可以進行使用者名稱和密碼的輸入,實現頁面互動,下面是ViewController的全部代碼。以前的錯誤也沒有刪除,以警示自己。

 1 #import "ViewController.h" 2  3 @interface ViewController () 4 @property(nonatomic, retain) UITextField* user;    // 使用者名稱輸入框 5 @property(nonatomic, retain) UITextField* pwd;    // 密碼輸入框 6 @end 7  8 @implementation ViewController 9 10 - (void)viewDidLoad {11     [super viewDidLoad];12     self.button = [[UIButton alloc] initWithFrame:CGRectMake(0, 100, [[UIScreen mainScreen] bounds].size.width, 20)];13     [self.button setTitle:@"跳轉" forState:UIControlStateNormal];14     [self.button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];15     [self.view addSubview:self.button];16     [self.button addTarget:self action:@selector(clickMe:) forControlEvents:UIControlEventTouchUpInside];17 18 } 19 -(void)clickMe:(id)sender{20     21     //初始化提示框;22      UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"您確定是否解除鎖定" preferredStyle: UIAlertControllerStyleAlert];23     [alert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {24         textField.placeholder = @"請輸入使用者名稱";25 //        UIView *myUserView = [[UIView alloc]initWithFrame:CGRectMake(22, 45, 240, 36)];26 //        myUserView.backgroundColor =  [UIColor redColor];27 //        self.user = [self createTextField:@"請輸入使用者名稱"28 //                                   withFrame:CGRectMake(22, 45, 240, 36)];29 //        [myUserView addSubview:self.user];30     }];31     [alert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) {32         textField.placeholder = @"請輸入密碼";33 //        self.pwd = [self createTextField:@"請輸入密碼"34 //                                   withFrame:CGRectMake(22, 82, 240, 36)];35     }];36     [alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {37         //點擊按鈕的響應事件;38         NSLog(@"取消提示");39     }]];40     [alert addAction:[UIAlertAction actionWithTitle:@"是的" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {41         //點擊按鈕的響應事件;42         NSLog(@"確定提示");43     }]];44     //彈出提示框;45     [self presentViewController:alert animated:true completion:nil];46 47 }48 //- (UITextField*)createTextField:(NSString*)placeholder withFrame:(CGRect)frame {49 //    UITextField* field = [[UITextField alloc] initWithFrame:frame];50 //    field.placeholder = placeholder;51 //    field.secureTextEntry = YES;52 //    //field.backgroundColor = [UIColor redColor];53 //    field.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;54 //    55 //    return field;56 //}57 - (void)didReceiveMemoryWarning {58     [super didReceiveMemoryWarning];59     // Dispose of any resources that can be recreated.60 }61 62 @end
View Code

 

iOS9 警告框

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.