UIAlertControllerStyleActionSheet 点击空白处不隐藏问题
iOS8之后使用UIAlertController 代替UIActionSheet, 如果不添加取消按钮, 点击空白处则不隐藏弹框;
所以点击空白处需要隐藏弹框的, 添加取消按钮即可.
UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet] ;
[alert addAction:[UIAlertAction actionWithTitle:@“拍照” style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
}]] ;
[alert addAction:[UIAlertAction actionWithTitle:@“从相册选择照片” style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
}]] ;
[alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
}]] ;
[self presentViewController:alert animated:YES completion:^{
}] ;
本文介绍在iOS开发中使用UIAlertControllerStyleActionSheet样式时,如何通过添加取消按钮实现点击空白区域关闭弹窗的功能。

1万+

被折叠的 条评论
为什么被折叠?



