UIAlertController* alert = [ UIAlertController alertControllerWithTitle: @"a" message: @"alert12222fdsfs" preferredStyle: UIAlertControllerStyleAlert] ;
UIAlertAction* defaultAction = [ UIAlertAction actionWithTitle: @"OK" style: UIAlertActionStyleDefault
handler: ^ ( UIAlertAction * action) {
} ] ;
UIAlertAction* cancelAction = [ UIAlertAction actionWithTitle: @"Cancel" style: UIAlertActionStyleDefault handler: ^ ( UIAlertAction * action) {
} ] ;
[ alert addAction: defaultAction] ;
[ alert addAction: cancelAction] ;
[ self presentViewController: alert animated: YES completion: nil] ;
UIAlertController* alert = [ UIAlertController alertControllerWithTitle: @"标题"
message: @"啊啊啊啊啊"
preferredStyle: UIAlertControllerStyleAlert] ;
UIAlertAction* okAction = [ UIAlertAction actionWithTitle: @"OK" style: UIAlertActionStyleDefault
handler: ^ ( UIAlertAction * action) {
for ( UITextField * text in alert. textFields) {
NSLog ( @"text = %@" , text. text) ;
}
} ] ;
UIAlertAction* cancelAction = [ UIAlertAction actionWithTitle: @"Cancel" style: UIAlertActionStyleCancel
handler: ^ ( UIAlertAction * action) {
NSLog ( @"action = %@" , alert. textFields) ;
} ] ;
[ alert addTextFieldWithConfigurationHandler: ^ ( UITextField * textField) {
textField. placeholder = @"用户名" ;
} ] ;
[ alert addTextFieldWithConfigurationHandler: ^ ( UITextField * textField) {
textField. placeholder = @"密码" ;
textField. secureTextEntry = YES;
} ] ;
[ alert addAction: okAction] ;
[ alert addAction: cancelAction] ;
[ self presentViewController: alert animated: YES completion: nil] ;
UIAlertView * alertView = [ [ UIAlertView alloc] initWithTitle: @"支付" message: @"10.0" delegate: self cancelButtonTitle: @"取消" otherButtonTitles: @"确定" , nil] ;
alertView. alertViewStyle = UIAlertViewStyleSecureTextInput;
[ alertView show] ;
4 UIAlertController显示ActionSheet
UIAlertController* alert = [ UIAlertController alertControllerWithTitle: @"aa"
message: @"Ta a a a "
preferredStyle: UIAlertControllerStyleActionSheet] ;
UIAlertAction* cancelAction = [ UIAlertAction actionWithTitle: @"取消" style: UIAlertActionStyleCancel
handler: ^ ( UIAlertAction * action) {
} ] ;
UIAlertAction* deleteAction = [ UIAlertAction actionWithTitle: @"删除" style: UIAlertActionStyleDestructive
handler: ^ ( UIAlertAction * action) {
} ] ;
UIAlertAction* saveAction = [ UIAlertAction actionWithTitle: @"保存" style: UIAlertActionStyleDefault
handler: ^ ( UIAlertAction * action) {
} ] ;
[ alert addAction: saveAction] ;
[ alert addAction: cancelAction] ;
[ alert addAction: deleteAction] ;
[ self presentViewController: alert animated: YES completion: nil] ;