Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 5    Views: 102

Graham90978
Aspiring developer
Profile
Posts: 23
Reg: Jul 31, 2014
Dublin
230
10/14/15 03:16 PM (9 years ago)

The dreaded black nav bar issue....

Hi Guys, I’m having a problem with one of my apps. I have a navigation bar at the top of the app. It was white with a home button on the top left, clicking the top right brings up a list of other screens on the app. The nav bar was white, but now its black. The text has disappeared and so has the buttons too, despite still working. I didn’t change the code at all. I googled this and it seems to have been a problem last year with iOS 7. I hate to bring up old problems, but I don’t quite know how to fix it. The following is code from the ‘*_appdelegate.m file’: if(floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1){ [self setStatusBarStyle:UIStatusBarStyleDefault]; } if(floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1){ [self setNavBarTitleTextColor:@"#FFFFFF"]; }else{ [self setNavBarTitleTextColor:@"#FFFFFF"]; } and the code from the BT_viewController.m is: [self configureNavBar]; I have no idea how to set the black background back to white, can anyone help? Is there code somewhere else that addresses this? I apologize if this question has been asked dozens of times before. I just couldn’t find an answer I could directly apply to my issue! Graham
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
10/14/15 05:41 PM (9 years ago)
Forgive my addled mind... I can't remember 'which' of these apply, but one or the other should work. From my notes part 1: https://www.buzztouch.com/forum/thread.php?fid=D52FB9DE2E730FC4BC1F2D5&tid=D52FB9DE2E730FC4BC1F2D5 If you don't mind playing with the code a little, you can set your NavBar Font attributes in your BT_viewController.m file. Look around line 382 or so, and 'after' you see the line "end setup Nav Bar" is where you'll want to put your code. You have to setup your own little 'dictionary' of attributes, but just use my settings and change the values to suit your needs. NSShadow *shadow = [[NSShadow alloc] init]; shadow.shadowColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8]; shadow.shadowOffset = CGSizeMake(0, 1); UIColor *myColor = [BT_color getColorFromHexString:@"#330033"]; NSDictionary *textola = [NSDictionary dictionaryWithObjectsAndKeys: myColor, NSForegroundColorAttributeName, shadow, NSShadowAttributeName, [UIFont fontWithName:@"chalkduster" size:21.0], NSFontAttributeName, nil]; [self.navigationController.navigationBar setTitleTextAttributes:textola]; From my notes part 2: http://www.appcoda.com/customize-navigation-status-bar-ios-7/ In BT_viewController.m 'around' line 408… replace: self.navigationController.navigationBar.titleTextAttributes = @{UITextAttributeTextColor:[BT_color getColorFromHexString:[appDelegate navBarTitleTextColor]]}; with this: NSDictionary *myCustomFontType = [NSDictionary dictionaryWithObjectsAndKeys:[UIFont fontWithName:@"Didot-Italic" size:12], NSFontAttributeName,[UIColor blueColor], NSForegroundColorAttributeName,nil]; //set the title text color using the value saved in the app's delegate... [self.navigationController.navigationBar setTitleTextAttributes:myCustomFontType]; ============== Hope this can help... Cheers! -- Smug
 
Graham90978
Aspiring developer
Profile
Posts: 23
Reg: Jul 31, 2014
Dublin
230
like
10/16/15 08:58 AM (9 years ago)
This worked a treat, thank you very much! I think the problem is that I have disconnected the app from accessing buzztouch online as its more or less self contained. This is possibly the reason why the nav bar went to black. This now gives rise to what appears to be a second issue: I dont have a left button on my nav bar anymore. Pressing it still brings you to the home menu. However the button isn't showing and it seems too be due to the disconnection Any chance you have a fix for this? A huge thank you in advance :) Graham
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
10/16/15 03:53 PM (9 years ago)
Well, if you disconnect the app from the BT Control Panel then the button will go away; no need to refresh. However, the Screen back buttons should still appear as textual buttons. If they're not showing up, you might try this: BT_viewUtilities.m From this: //line 326 //navLeftTap or closeChildApp UIBarButtonItem *theBackButtonItem = theBackButtonItem = [[UIBarButtonItem alloc] initWithTitle:backText style:UIBarButtonItemStylePlain target:theViewController action:@selector(navLeftTap)]; [theViewController.navigationItem setLeftBarButtonItem:theBackButtonItem]; [theBackButtonItem release]; --------------------------------------------- To this: UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom]; UIImage *backButtonImage = [UIImage imageNamed:@"navbar-back"]; [backButton setBackgroundImage:backButtonImage forState:UIControlStateNormal]; [backButton addTarget:theViewController action:@selector(navLeftTap) forControlEvents:UIControlEventTouchUpInside]; backButton.frame = CGRectMake(0, 0, 55, 30); [backButton setTitle:@" Back" forState:UIControlStateNormal]; UIBarButtonItem *theBackButtonItem = [[UIBarButtonItem alloc] initWithCustomView:backButton];; [theViewController.navigationItem setLeftBarButtonItem:theBackButtonItem]; [theBackButtonItem release]; *********** another submission below ************** UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom]; UIImage *backButtonImage = [UIImage imageNamed:@"backbutton.png"]; [backButton setBackgroundImage:backButtonImage forState:UIControlStateNormal]; [backButton addTarget:theViewController action:@selector(navLeftTap) forControlEvents:UIControlEventTouchUpInside]; backButton.frame = CGRectMake(0, 0, 55, 30); [backButton setTitle:@" Back" forState:UIControlStateNormal]; // define fontsize [backButton setFont:[UIFont boldSystemFontOfSize: 12]]; // Alternative code below to define a specific font // [backButton setFont:[UIFont fontWithName: @"Helvetica" size:12.0]]; // Set the Text Color [backButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; [backButton setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted]; ____________________________________________ As usual, no warranty expressed or implied. Cheers! -- Smug
 
Graham90978
Aspiring developer
Profile
Posts: 23
Reg: Jul 31, 2014
Dublin
230
like
10/18/15 03:45 AM (9 years ago)
Thanks for the response Smug! So I can’t find an exact match to the code you described appearing at line 326. The code that does appear however is : UIBarButtonItem *theBackButtonItem = theBackButtonItem = [[UIBarButtonItem alloc] initWithTitle:backText style:UIBarButtonItemStylePlain target:self action:sel]; [self.navigationItem setLeftBarButtonItem:theBackButtonItem]; I tried replacing this with the code you provided and there was no change. Do you know what I am doing wrong? I changed “theViewController” with “self” to make the code you provided fit with what I had. Have you seen this happen before? Odds are I’m missing something completely simple! Is it possible theres something that needs to be changed in the app Delegate file? Graham
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
10/18/15 04:28 AM (9 years ago)
Yeah... Mea Culpa. sorry about that; I was just grabbing old snippets from my code library, and it's probably something from BTv2... I'm working on another client project, so while I had xcode open, I found out we probably need to be working in 'BT_viewController.m', starting around line 250-ish... That's where the back button is created and setup. The first portion (lines 250 to 262ish) sets up the 'refresh' button for the 'home' screen. The rest of the code (lines 263ish to 289) is for the 'other screens'. That's where you'll want to play around. It might also be worth noting that although the code sometimes will designate 'prev.png' as a back button image, that image doesn't exist in your BT project. You might try adding a suitable image named 'prev.png' to your project and see if that fixes your issue. Cheers! -- Smug
 

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.