关于iOS中提示框的使用

关于iOS中提示框的使用
在iOS8的SDK里,已经对提示框进行了更改,现在属于 UIAlertController,其接口如下声明NS_CLASS_AVAILABLE_IOS(8_0) @interface UIAlertController : UIViewController,不再是一个UIView。

具体的使用如下,希望对某些朋友有帮助。
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_8_0 //判断你当前的iOS SDK所支持的最大iOS系统版本
    if (SystermVersion >= 8.0) {
        UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"提示" message:@"这是iOS8.0版本以上警告框的用法" preferredStyle:UIAlertControllerStyleAlert]; //通过preferredStyle参数选择是Alert还是Sheet。
        
        UIAlertAction *sureAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction *alertAction){
//按钮被点击后响应不再通过代理处理,而是通过black体回调
            NSLog(@"确定按钮被点击,测试成功");
        }];
       
        UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction *alertAction){
            NSLog(@"取消按钮被点击,测试成功");
        }];
        
        [alertVC addAction:sureAction];
        [alertVC addAction:cancelAction];
        
        [self presentViewController:alertVC animated:YES completion:^{NSLog(@"跳转成功");}];
    }
    else
    {
        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"这是 iOS8.0版本以下警告框的用法" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
        [alert show];
    }
#else
    {
        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"这是 iOS8.0版本以下警告框的用法" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
        [alert show];
    }
#endif
    
}

转载于:https://www.cnblogs.com/iOS-kk/p/5207564.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值