iphone - Presenting UINavigationController modally -- problem setting up tool and nav bar items in root view controller viewDidLoad -
In my iOS app I am creating and presenting a UI controller such as:
MyViewController * myvc = [[[MyViewController alloc] initWithNibName: @ "MyViewController" bundle: zero] Autorege]; UINavigationController * navVC = [[[UINavigationController alloc] initWithRootViewController: myvc] autorelease]; [Self-Present Model View Controller: Animated NVV: Yes]; I am creating and installing toolbar items for the Navigation Controller toolbar, so in MyViewController viewDidLoad:
self.navigationController.toolbar .items = [NSARRArrayView Object: (item ...), zero]; The problem I am experiencing is that the items are not visible, instead I call a method from MyViewController viewDidLoad method which adds toolbar items via display: WithObject: afterDelay: 0, then it works perfectly, so clearly introducing the initial presentation of the UIinaging controller, the initialization of its toolbar / navbar, and the specific initial route view controller of the nav bar. Here are some race conditions.
I have verified in the debugger that the view of the root view controllerDidload is called after the viewDidload method of the UIAV control. In fact, the root is called the view controller's viewDidLoad method presentModalViewController: called, and called within ViewDidLoad InitWithRootViewController the UINavigationController, so that it does not indicate that should UINavigationController object "ready to go" , And Toolbar with its navigation bar?
I toolbar was previously thought that the navigation controller object are not yet present on viewDidLoad time MyViewController, but it clearly is less than, NSLog shows that during Drishydidlod method MyViewController from Is not zero. In fact, the toolbar object of the UINavigationController is the same at all times: withObject: in the ViewDidLoad of the Root View Controller, and in the "setupToolbar" method that I have called with PerformSelector. AfterDelay, then this is not happening "restart" anyway
So, what's going on here? Why my toolbar modifications are not "sticking" in the viewDidLoad of MyViewController, and why they show up in the next step of runloop (performSelector: withObject: afterDelay: 0) What's this
? "How to set up the initial navbar / toolbar item in the code from the UINavigationController's Root ViewController?
EDIT: Well I thought "what" is happening, even though I still do not understand "why": After returning view of myViewController viewDidLoad method (where I verified it Navigation Controller's item array -nil) and before some time / next runloop travel (or whenever in a performSelector: withObject: afterDelay: 0), the item property of the navigation controller is set to zero.
EDIT: One Same When calling [self.navigationController setToolbarItems: animated:]
Edit: Solution, the right way is [self setToolbarItems: animated:], no [self.navigationController setToolbarItems: animated:] !, thanks < / P>
Just an estimate here, but you have tried to use it
[self setToolbarItems: [NSArray arrayWithObjects: (item ...), zero] animated: no]; MyViewController's ViewDidload method from ? I'm not sure that this is the right way to access Toolbar navigation directly on the navigation controller as you did at least API states
UIViewController class reference
...
- (zero) setToolbarItems: (NSArray *) toolbar animations animated: (BOOL) animated ... < Blockquote>
View the controllers managed by a navigation controller can use this method to specify the toolbar item Navigation Toolbar's built-in toolbar allows you to set toolbar items for your view controller after your view controller appears before or even before it's displayed.
Comments
Post a Comment