项目中遇到的问题(一)弹出UIAlertController 时出现 Warning: Attempt to present * on * which is already presenting

来源:互联网 发布:蓝韵网络 编辑:程序博客网 时间:2024/05/30 23:51

UITableView 显示的是城市的信息
在点击Cell 执行
-(void)tableView:(UITableView *)tableView              didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
  1.方法时创建UIAlertController 对象并添加UIAlertAction 

这时调用
[self presentViewController:controller animated:YES completion:nil];
可以弹出action sheet.


*******出错处!!!!!
给tableview 加上  UISearchController

搜索成功的数据更新以后再点击cell时,执行

[self presentViewController:controller animated:YES completion:nil];出错原因是: Warning: Attempt to present * on * which is already presenting


解决方法:例如infoArray 是搜索结果保存的数组,在

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

[selfdismissViewControllerAnimated:YEScompletion:nil]];


  [infoArray objectAtindex: indexPath.row]; 之前加上上面这句 即可解决。

2 0
原创粉丝点击