iOS UIALertViewController常用方法

来源:互联网 发布:程序算法 编辑:程序博客网 时间:2024/06/10 00:03

     在iOS 8之后,UIAlertView和UIActionSheet方法都废弃了,在XCode7.0版本之前还不会提示,在7.0之后的版本这俩者会报红提示方法废弃。

"UIActionSheet is deprecated. Use UIAlertController with a preferredStyle of UIAlertControllerStyleActionSheet instead"

"UIAlertView is deprecated. Use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert instead"

      在苹果的文档中,代替倆者的方法是UIAlertController。

      UIAlertController有俩种 preferredStyle,分别是UIAlertControllerStyleActionSheet和UIAlertControllerStyleAlert。这俩种方式代表俩种不同的布局分别对应之前的ActionSheet和AlertView。

      创建初始化AlertController:

UIAlertController *alertC = [UIAlertController alertControllerWithTitle:@"1" message:@"1" preferredStyle:UIAlertControllerStyleActionSheet];

[self.navigationController presentViewController:alertC animated:YES completion:nil];



0 0
原创粉丝点击