how can i add buttons to my navigation controller toolbar,so that i can see them in all views

。_饼干妹妹 提交于 2020-01-06 07:18:10

问题


I AM HAVING nav controller and in main view.nib i added two buttons on to tool bar and i should view these in next views also,but iam not able to see right now those in next view , where i hav to add these so i can see these buttons or access in any view ....

any help appreciated...


回答1:


Quick and easy way is to set the toolbar items for new view controller, before you push it.

// Assuming self.toolbarItems is already set.
UIViewController *newViewController = [[[UIViewController alloc] init] autorelease];

[newViewController setToolbarItems:self.toolbarItems];

[self.navigationController newViewController animated:YES];

If you're finding applying this method before each pushing tedious, then you can subclass all your UIViewController implementations, and have it's toolbar be set, once and for all. :)




回答2:


You would need to set the toolbarItems property of each view.

When displayed, this toolbar obtains its current set of items from the toolbarItems property of the active view controller. When the active view controller changes, the navigation controller updates the toolbar items to match the new view controller, animating the new items into position when appropriate.

http://developer.apple.com/iphone/library/documentation/uikit/reference/UINavigationController_Class/Reference/Reference.html



来源:https://stackoverflow.com/questions/3247422/how-can-i-add-buttons-to-my-navigation-controller-toolbar-so-that-i-can-see-them

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!