简体   繁体   中英

Unable to remove BackButton in Navigation controller using Storyboard in ios

I am new to iOS,

I am developing shopping App for IPhone using Storyboard,

Here is the snapshot of my App, TabBarController contains 4 Tab with NavigationController

When i open Tab1 (let say class1 ) it contains TableView , onclick of tableview it will take me to Detail page with title and back button on NavigationBar (I am adding title and back button programatically in ViewWillAppear method ) after this when i hit back button i navigates to previous page properly, this is working fine..

My problem is When i open Tab1 (ie class1) and when i navigates to Detail page after selecting a row in tableview, in a Detail page , BackBtn and title will be added in NavigationBar bcoz ViewWillAppear method will be called, and when i hit Tab2 before hitting Backbtn, i am navigates to class of Tab2 and thn when i comes back to Tab1 and now i clicks on back button i am navigating to previous page of my Tab1 class (ie class1 ) but on class1 back Button and title of Detail page is there on my class1 i am unable to hide it...

You can see in the 2nd image BackBtn and Title is there in Class1 .. What's the problem ?

just hide that backButton in viewWillAppear: method of Class1 like bellow...

[self.navigationItem setHidesBackButton:YES animated:YES];

or

[self.navigationItem setHidesBackButton:YES];

UPDATE:

if you add custom button to the UINavigationBar then just remove that button like bellow...

self.navigationItem.leftBarButtonItem = nil;

and if you want to remove right bar button then use bellow another code like above...

self.navigationItem.rightBarButtonItem = nil;

i hope this helpful to you...

viewWillDisapper: [btnBack setHidden:YES]详细信息”页面中的方法

- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item

Will give you which item you are currently selecting.

You can work around if you cant fix it by popping to root view controller and pushing it again. And make sure you are not adding a subview in place of pushing a view controller.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM