zoukankan      html  css  js  c++  java
  • ios8 UIAlertController

    ios8 上面,用UIAlertController将UIAlertView和UIActionSheet合二为一了。 

    (1)创建普通alert

        UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title  message:message  preferredStyle:UIAlertControllerStyleAlert];
        
        // Create the actions.
        UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:cancelButtonTitle  style:UIAlertActionStyleCancel  handler:^(UIAlertAction *action) {
            NSLog(@"The "Okay/Cancel" alert's cancel action occured.");
        }];
        
        UIAlertAction *otherAction = [UIAlertAction actionWithTitle:otherButtonTitle  style:UIAlertActionStyleDefault  handler:^(UIAlertAction *action) {
            NSLog(@"The "Okay/Cancel" alert's other action occured.");
        }];
        
        // Add the actions.
        [alertController addAction:cancelAction];
        [alertController addAction:otherAction];
        
        [self presentViewController:alertController animated:YES completion:nil];

    如果UIAlertAction *otherAction这种otherAction多几个的话,它会自动排列成一列。

    (2)带有输入框的alert

    如果需要在 alertview上面添加输入框等,如下:
    [alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
            // 可以在这里对textfield进行定制,例如改变背景色
            textField.backgroundColor = [UIColor orangeColor];
        }];
  • 相关阅读:
    javaScript对象
    javaScript基础
    使用javaScript和JQuery制作经典面试题:光棒效果
    Animate自定义动画
    使用jQuery快速高效制作网页交互特效
    jQuery中绑定事件bind() on() live() one()的异同
    小笔记1(Get请求)

    this关键字
    Eclipse断点调试(下)
  • 原文地址:https://www.cnblogs.com/417460188dy/p/3978824.html
Copyright © 2011-2022 走看看