iOS弹出提示框

在iOS8之后,弃用了UIAlertView(我倒是很喜欢用这个,用着正顺手呢,不理解为什么要删掉),不过现在的UIAlertController也有她的有点。

现在的提示框是UIAlertController和UIAlertAction相结合

具体实现,如下:

 UIAlertController *alertController=[UIAlertController alertControllerWithTitle:@"温馨提示" message:@"    身份一经确定,不可更改!如果您正准备考研,请『取消』后选择『我是学员』" preferredStyle:UIAlertControllerStyleAlert];

    

    //确认

    UIAlertAction *confirmAction=[UIAlertAction actionWithTitle:@"确认" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {

       // 点击确认按钮时触发的事件

        // PerfectInformationViewController *perfectinformationVC=[[PerfectInformationViewController alloc] initWithNibName:@"PerfectInformationViewController" bundle:nil];

       // [self.navigationController pushViewController:perfectinformationVC animated:YES];

        

    }];

    

    //取消

    UIAlertAction *cancelAction=[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {  

 // 点击取消按钮时触发的事件           

    }];

 

    [alertController addAction:confirmAction];

    [alertController addAction:cancelAction]; 

    [self presentViewController:alertController animated:YES completion:nil];

一个人,一片天,一条路,一瞬间!
原文地址:https://www.cnblogs.com/zcl410/p/4953225.html