uiviewcontroller - iOS: Presenting new views whose interface is loaded from a xib file and contain a Navigation Controller -
there's fundamental i'm not understanding presenting views interface xib file.
my app's root view controller uitabbarcontroller. 1 of tab bar options presents uinavigationcontroller-controlled view. 1 navigation bar of view, have plus (+) button adding new item. want present additem view modal view, , should take interface additemview.xib file. xib file has in navigation controller.
however, navigation bar doesn't appear. here's function gets called when clicking on plus button:
- (void)shownewview:(uiviewcontroller *)viewcontroller { additemviewcontroller *vc = [[additemviewcontroller alloc] initwithnibname:@"additemviewcontroller" bundle:nil]; //viewcontroller uiviewcontroller on plus button tapped [viewcontroller.navigationcontroller presentmodalviewcontroller:vc animated:no]; } all white screen. need in viewdidload additemviewcontroller? need connect uinavigationcontroller instance in xib?
all seems work tab bar, in mainwindow.xib file. uitabbarcontroller there has uinavigationcontroller under it, in turn has subclass of uitableviewcontroller under it, , in turn contains uitableview initial content see on screen when tapping on corresponding option in tab bar. i'm not sure why sticking things in ib doesn't cause same happen.
as said in beginning, i'm sure problem stems fundamental misunderstanding relationship between xib files, view controllers, , view controllers call upon them. while want particular issue solved, i'd love answer can address broader misunderstanding.
the view controller you're presenting vc, additemviewcontroller. it's not enough there's navigation controller in .xib file -- have use it. ;-)
check out listing 6-1 in presenting view controller modally example of 1 way want. if want use nav controller that's in .xib, make outlet , present rather additemviewcontroller you're presenting.
all seems work tab bar, in mainwindow.xib file. uitabbarcontroller there has uinavigationcontroller under it, in turn has subclass of uitableviewcontroller under it, , in turn contains uitableview initial content...
all objects in mainwindow.xib loaded @ same time , connected each other. don't have tab bar connected directly table view controller, right? have connected navigation controller. when corresponding tab tapped, tab bar controller doesn't know thing table view controller -- asks nav controller view, , navigation controller asks table view controller its view, layers navigation views (see anatomy of navigation interface) , returns result tab bar controller.
imagine happen if did connect tab bar controller directly table view controller. time, tab bar controller talking table view controller directly, when asks tab's view controller view, gets table view controller's view, i.e. table, no navigation features.
the same thing happening modal view controller. since you're presenting additemviewcontroller , not navigation controller, additemviewcontroller get.
Comments
Post a Comment