开发者

how to remove a navigation controller with a view

I have a tabbar application with a navigation bar. For one of the actions I am instantiating a navigation controller programatically and adding a view with tableview. I want to remove this navigation bar and tableview programatically clicking a button on the new navigation bar. how to do this ?

I tried popview but it is not poping 开发者_运维问答out.


To hide it

[[self navigationController] setNavigationBarHidden:YES];

If you have added a UINavigationController on top of another UIViewController, then from the uiNaviagation controller, you will not be able to remove the navigation bar even if you remove the current view, and all the subview. (the parent uiviewcontroller also get the nav bar)

One way to fix this is, access the app delegate, and remove the top view from the window before adding the UINavigationController

AppDelegate *dg = (AppDelegate *)[[UIApplication sharedApplication] delegate]; 
NSArray *ar = [[dg window] subviews];
//then remove all the views in ar
//then add uinavcontroller
[[dg window] addSubView:[uinavcontroller view]];

then add UINavigationController, when you want to replace the UInavigationcontroller with the first UiViewController. do the similar steps like above.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜