self.alertController=[UIAlertController alertControllerWithTitle:@"请选择\n\n\n\n\n\n\n\n\n\n\n\n\n\n" message:nil preferredStyle:UIAlertControllerStyleActionSheet];
//定义一个AlertAction ,style 选择Destructive 确定按钮,handler中是处理方法
UIAlertAction *destAction=[UIAlertAction actionWithTitle:@"确定"
style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
[self selectDataFromPick];//选择数据
}];
[self.alertController addAction:destAction]; //视图控制器添加方法 [self.alertController.view addSubview:self.picker];//添加子视图
(2)带有输入框的alert
如果需要在 alertview上面添加输入框等,如下:
[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
// 可以在这里对textfield进行定制,例如改变背景色
textField.backgroundColor = [UIColor orangeColor];
}];