iOS 开发中关于弹窗的几种方式

来源:互联网 发布:js获取div的id值 编辑:程序博客网 时间:2024/05/17 23:10


1.IOS8以前的方式:

 UIAlertView *alertView = [[UIAlertView alloc]initWithTitle:@"提示" message:@"输入的数字不合理" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:nil, nil];   [alertView show];

2.IOS8以后最新方式:ios 9 推荐使用,ios7的在ios9中已过期

   *ios8创建弹框的方法:

UIAlertController *alertVc =[UIAlertController alertControllerWithTitle:@"提示" message:@"输入数字不合理" preferredStyle:UIAlertControllerStyleAlert];
   *ios8显示弹框的方法:
[self presentViewController:alertVc animated:NO completion:nil];

   *ios8添加按钮的方法:

[alertVc addAction:[UIAlertActionactionWithTitle:@"取消" style: UIAlertActionStyleCancel handler:^(UIAlertAction*action) { NSLog(@"点击了取消按钮");

3.actionsheet弹窗:(底部弹窗)

       UIActionSheet *sheet = [[UIActionSheetalloc]initWithTitle:@"确定要注销?" delegate:selfcancelButtonTitle:@"取消" destructiveButtonTitle:@"确定" otherButtonTitles:nil,nil];

       [sheet showInView:self.view];

   - (void)actionSheet:(UIActionSheet *)actionSheetclickedButtonAtIndex:(NSInteger)buttonIndex

    {

       if (buttonIndex ==0) {

           [self.navigationControllerpopViewControllerAnimated:YES];

       }

    }

1 0
原创粉丝点击