1. 程式人生 > >ios UISearchController ios 11.4.1版本 Application tried to present modal view controller on itself

ios UISearchController ios 11.4.1版本 Application tried to present modal view controller on itself

最近發現bugly記錄了這樣的bug,都集中在了ios 11.4.1版本上面,並且只出現了 2次,無法復現,所以就是看程式碼,各種查閱了,最後找了這麼一個有用的文章https://stackoverflow.com/questions/31487824/error-application-tried-to-present-modal-view-controller-on-itself-while-activ

 

[searchController setActive:NO]設定UISearchController 的active狀態來解決UISearchController重複彈出viewController,因為active是UISearchController的活躍狀態,設定之後將會無法彈出。因此

- (void)didDismissSearchController:(UISearchController *)searchController

{

    BLYLogInfo(@"----------%s--" , __PRETTY_FUNCTION__);

    [searchController setActive:NO];

 

}

在UISearchControllerDelegate的dismiss方法上面將UISearchControlleter Active設定為NO,後續待觀察