关闭

iOS&OS X -- Alert 提示框实现

596人阅读 评论(0) 收藏 举报
分类:

31st,May,2016

iOS实现UIAlert

Important: UIAlertView is deprecated in iOS 8. (Note that UIAlertViewDelegate is also deprecated.) To create and manage alerts in iOS 8 and later, instead use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert. – from Apple Doc

iOS 8以前 (deprecated)

- (instancetype)initWithTitle:(NSString *)title
                      message:(NSString *)message
                     delegate:(id)delegate
            cancelButtonTitle:(NSString *)cancelButtonTitle
            otherButtonTitles:(NSString *)otherButtonTitles,

iOS8 and later

// from apple
UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"My Alert" message:@"This is an alert."
                          preferredStyle:UIAlertControllerStyleAlert];

UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
   handler:^(UIAlertAction * action) {}];

[alert addAction:defaultAction];
[self presentViewController:alert animated:YES completion:nil];

OS X实现NSAlert

OS X实现提示框

anAlert.showsSuppressionButton = YES; // Uses default checkbox title
anAlert.suppressionButton.title = @"Do not show this warning again";
0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:93659次
    • 积分:1907
    • 等级:
    • 排名:千里之外
    • 原创:109篇
    • 转载:1篇
    • 译文:0篇
    • 评论:1条
    最新评论