Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 5    Views: 91

Janeen
Aspiring developer
Profile
Posts: 51
Reg: Jun 11, 2013
Southern Califo...
6,910
04/08/14 08:51 PM (10 years ago)

Remove Back button in Advanced Menu and Advanced Quiz Plugins

Hello all, I'm working on my first iPhone app and slowly jumping one hurdle at a time. Right now I'm stuck on trying to remove the back button within both the Advanced Quiz and Advanced Menu plugins because I only want the Right Nav Button available to take you to the top level menu in my app. I searched the forum and found a few posts, but I've not been able to find the code snippets referenced in the posts within the .m file. For instance, I've searched in the NAD_advanced_quiz.m file for the "configureBackgroundAndNavBar" that is supposed to be just after the "viewWillAppear", but it's not there. In fact, "configureBackgroundAndNavBar" is not anywhere in the .m file. The same is true for the CR_menu_advanced.m file. Does anyone have any ideas as to how I can remove that Back button from my top Nav bar? Thanks! Janeen
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
04/08/14 09:30 PM (10 years ago)
This code has been moved to the parent class, BT_viewController.m. You can override this in the viewWillAppear method of the plugin class by copying all but the relevant code from BT_viewController into viewWillAppear for the plugin, and deleting the [super viewWillAppear]; call.
 
PaddyO
Lost but trying
Profile
Posts: 189
Reg: Sep 11, 2013
Geelong
5,190
like
04/09/14 12:17 AM (10 years ago)
Janeen when you find the bits you're looking for as per Chris's post, this snippet might help. It may not be overly elegant defining something to be deliberately invisible and action-less but it worked for me: //Left nav button will be an invisible text only button that has no action. If we don't declare it this way, it will show its default. UIBarButtonItem *listItem = [[UIBarButtonItem alloc] initWithTitle:@"" style (UIBarButtonItemStylePlain) target:nil action:nil]; NSArray *actionButtonItems = @[listItem]; self.navigationItem.leftBarButtonItems = actionButtonItems; There's an array in there that isn't really necessary (in your case) because it's only for one item, but this snippet will let you apply it to other buttons that you can add to the array if you need to, in the same bit of code. You'll also want to put a conditional 'if' before this if you want to isolate the effect of the code to just one (or more) screens, otherwise you'll lose your back buttons on every screen in your app. Cheers Paddy
 
Janeen
Aspiring developer
Profile
Posts: 51
Reg: Jun 11, 2013
Southern Califo...
6,910
like
04/09/14 05:42 AM (10 years ago)
Thanks, gents! I will try this tonight when I get home from work! Janeen
 
Janeen
Aspiring developer
Profile
Posts: 51
Reg: Jun 11, 2013
Southern Califo...
6,910
like
04/11/14 12:28 PM (10 years ago)
Chris1, I've been staring at the code, trying to decide what is meant by "copying all but the relevant code". I've tried different things, but nothing has worked so far. I did see this snippet of code at line 1107 of the BT_viewController.m file, and I was wondering if it was relevant and how to use it: //always hide the "back" button. A custom button is added in BT_viewUtilities.configureBackgroundAndNavBar [theNextViewController.navigationItem setHidesBackButton:TRUE]; I've trying to solve this by reading through and applying different suggestions I've found in the forum, but now I feel like I'm confusing myself. Would you be able to tell me a bit more about how to implement your solution by telling me what line numbers should be removed from the BT_viewController and inserted at what line number in the plugin? Many thanks! Janeen
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
04/14/14 10:06 PM (10 years ago)
Actually, I think PaddyO's solution is probably the simplest.
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.