Can't use AlertController with SearchController

Hi,

I have a UITableView to which I've added search capability using UISearchController. The search basically helps filter a potentially long table. The search works fine. But once the items are dispalyed using UISearchController I have a toolbar that allows things to be done on the items found; for example, share or delete. All my operations are always confirmed with a UIAlertController. But when I try to display my UIAlertController (still with the SearchController active) I get the message:


Warning: Attempt to present <UIAlertController: 0x7b847250> on <DataTableViewController: 0x7c9b9e00> which is already presenting <UISearchController: 0x7b8cabe0>


If I have t force the app to exit searchcontroller then th user looses the benefits of being able to search.


Is there a way to work around this issue?


Suggestions, please.

Accepted Answer

If DataTableViewController is a child a of UINavigationController you may use the navigation controller to present the alert from. Or you may check if the SerachController is active and present the alert using the searchController. However I don't like both of these workarounds. 🙂 They both seem a bit like a hack to me.


Dirk

I figured out the issue before I saw your email. It turned out to be your second option. Its my first time using UISearchController which is pretty much managed behing the scenes by IOS. So, when I go to present my UIAlertView I simply need to check if my UISearchController is active and if so use it to present the alertview; otheriwse, use the the UITableView.


I'll have to check my profile settings because I'm not getting email replies since this new forum started. Needless to say, it's had a rough start!

Can't use AlertController with SearchController
 
 
Q