一、UIAlertView
//定义属性
UIAlertView *AlertView;
//方法点击显示弹窗
AlertView = [[UIAlertView alloc]initWithTitle:@"确定" message:@"哈哈" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"多少啊", nil];
//需要show展示出弹窗,不是[self.view addSubView:]
[AlertView show];
//ios9 以后所用的弹窗
alert = [UIAlertController alertControllerWithTitle:@"Title" message:nil preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction * alert1 = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"点击了1");
//换成点击方法跳转方法
}];
UIAlertAction * alert2 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSLog(@"点击了2");
//换成点击方法跳转方法
}];
[alert addAction:alert1];
[alert addAction:alert2];
[self presentViewController:alert animated:YES completion:nil];
网友评论