UIAlertController的使用技巧
由于在iOS8之后,苹果将UIAlertView和UIActionSheet两者进行了整合,用UIAlertController来代替
- 如何创建UIAlertController
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"注 销" message:@"是否需要注销" preferredStyle: UIAlertControllerStyleAlert];
- 如何创建UIAlertAction
UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"取 消" style:UIAlertActionStyleCancel handler:nil];
- 如何将UIAlertAction添加至UIAlertController
[_alertController addAction:action1];
- 如何使得UIAlertController显示TextField
[_alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.placeholder = @"请输入账号";
}];