ios - How to open a modal with UITabBarController and on close, display last tab bar view? -


so have uitabbarcontroller on 1 storyboard has 3 buttons. 2 of them open standard views associated tab bar standard view association segues... third item issue.

i open form lives in storyboard (shared other views in app) in modal view, , upon close or submit, return whatever tab active in tabbed view.

i've seen few "options" out there, none of them seem looking do.

any ideas?

edit: got edited out of original question mod, writing in swift...not obj-c.

so have potential solution works using blank view controller, shouldselectviewcontroller , uitabbarcontroller delegate. issue is, i'm not particularly happy how brittle is.

func tabbarcontroller(tabbarcontroller: uitabbarcontroller, shouldselectviewcontroller viewcontroller: uiviewcontroller) -> bool {      // bit dangerous if move 'newcontroller' located in tabs, break.     let newcontroller = viewcontrollers![1] as! uiviewcontroller      // check if view load second tab , if is, load modal form instead.     if viewcontroller == newcontroller {         let storyboard = uistoryboard(name: "modalcontroller", bundle: nil)         let vc = storyboard.instantiateinitialviewcontroller() as? uiviewcontroller          presentviewcontroller(vc!, animated: true, completion: nil)          return false     } else {         return true     } } 

this works fine, if come along , re-arrange order of tabs in storyboard, break.

also give @rmp credit, options "if provide title of root viewcontrollers make tabs in tabbarcontroller you can use viewcontroller.title check tab tapped in shouldselectviewcontroller delegate. of course still run risk of renaming views title property."


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -