ios - Warning: Attempt to present * on * which is already presenting (null) -
this first application ios.
so have uiviewcontroller
uitableview
have integrated uisearchbar
, uisearchcontroller
in order filter tablecells display
override func viewdidload() { menubar.delegate = self table.datasource = self table.delegate = self let nib = uinib(nibname: "itemcelltableviewcell", bundle: nil) table.registernib(nib, forcellreuseidentifier: "cell") let searchbutton = uibarbuttonitem(barbuttonsystemitem: .search, target: self, action: "search:") menubar.topitem?.leftbarbuttonitem = searchbutton self.resultsearchcontroller = ({ let controller = uisearchcontroller(searchresultscontroller: nil) controller.searchresultsupdater = self controller.dimsbackgroundduringpresentation = false return controller })() self.table.reloaddata() }
i using modal segue in order open element's viewcontroller
display details of element.
func tableview(tableview: uitableview, didselectrowatindexpath indexpath: nsindexpath) { self.index = indexpath.row self.performseguewithidentifier("itemdetailfromhome", sender: self) } override func prepareforsegue(segue: uistoryboardsegue, sender: anyobject?) { if (segue.identifier == "itemdetailfromhome") { let settingsvc = segue.destinationviewcontroller as! itemdetailviewcontroller settingsvc.parent = self if self.issearching == true && self.searchtext != nil && self.searchtext != "" { settingsvc.item = self.filtereditems[self.index!] } else { settingsvc.item = self.items[self.index!] } } }
that works fine until try display itemdetailviewcontroller
filtered element (through uisearchcontroller
).
i have following message :
warning: attempt present <itemdetailviewcontroller: *> on <homeviewcontroller: *> presenting (null)
at every time going itemdetailviewcontroller.viewdidload()
function after when search activated have previous error.
any idea ? have tried use following async dispatch without success
func tableview(tableview: uitableview, didselectrowatindexpath indexpath: nsindexpath) { self.index = indexpath.row dispatch_async(dispatch_get_main_queue(), { () -> void in self.performseguewithidentifier("itemdetailfromhome", sender: self) }) }
i have found out solution.
i have add following code in homeviewcontroller.viewdidload
, works !
definespresentationcontext = true
Comments
Post a Comment