Welcome, Guest
Username Password: Remember me

nav bar color on a modal iPad detail view
(1 viewing) (1) Guest
  • Page:
  • 1
  • 2

TOPIC: nav bar color on a modal iPad detail view

nav bar color on a modal iPad detail view 1 year, 4 months ago #1

How do I set the navigation bar style on a modal iPad detail view? I have this:
 
SCArrayOfObjectsSection *section = [SCArrayOfObjectsSection sectionWithHeaderTitle:nil withItems: self.mySubscriptions withClassDefinition:subscriptionClass];
section.allowAddingItems = YES;
section.allowDeletingItems = YES;
section.addButtonItem = self.navigationItem.rightBarButtonItem;
section.detailViewModalPresentationStyle = UIModalPresentationFormSheet;
section.detailViewModal = YES;
[tableModel addSection:section];
 
 


and then this delegate call back:
 
-(void)tableViewModel:(SCTableViewModel *)tableViewModel detailViewWillAppearForSectionAtIndex:(NSUInteger)index withDetailTableViewModel:(SCTableViewModel *)detailTableViewModel {
DLog(@"Adding new subscription");
detailTableViewModel.delegate = self;
detailTableViewModel.viewController.navigationController.navigationBar.barStyle = UIBarStyleBlack;
detailTableViewModel.viewController.title = @"Add New Subscription";
[self setSubscriptionFooter: detailTableViewModel];
 
}
 


but this has no effect. The navigation bar appears to be completely transparent. The white title is hard to read and the buttons are dark blue.

Any ideas?

Thanks,

Frank
  • fsauer
  • OFFLINE
  • Fresh Boarder
  • Posts: 14
  • Karma: 1

Re: nav bar color on a modal iPad detail view 1 year, 4 months ago #2

Hi Frank,

Does your view controller (the one with the table view model) exist on a UINavigationController stack?
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2402
  • Karma: 72

Re: nav bar color on a modal iPad detail view 1 year, 4 months ago #3

The whole thing starts in a popover like this:
 
SubscriptionTVC *subUI = [[SubscriptionTVC alloc] initWithNibName:@"SubscriptionTVC" bundle:nil];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:subUI];
nav.navigationBar.barStyle = UIBarStyleBlack;
UIPopoverController *subPop = [[UIPopoverController alloc] initWithContentViewController:nav];
subPop.passthroughViews = nil;
subPop.delegate = self;
[subPop presentPopoverFromBarButtonItem: menuItem permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
self.subscriptionPopoverController = subPop;
[nav release];
[subPop release];
 
 



Note that I added UIBarStyleBlack here as well because I noticed it is inherited from parent navigation controllers so setting it here - I thought - would fix it. It did not.
  • fsauer
  • OFFLINE
  • Fresh Boarder
  • Posts: 14
  • Karma: 1

Re: nav bar color on a modal iPad detail view 1 year, 4 months ago #4

it turns out that if I do this:
 
if(navController)
//detailNavController.navigationBar.barStyle = navController.navigationBar.barStyle;
detailNavController.navigationBar.barStyle = UIBarStyleBlack;
 


on line 965 of SCTableViewSection.m the nav bar turns black. Hopefully this points to the real cause...

Thanks,

Frank
  • fsauer
  • OFFLINE
  • Fresh Boarder
  • Posts: 14
  • Karma: 1

Re: nav bar color on a modal iPad detail view 1 year, 4 months ago #5

and to make the nav bar appear black both for editing and adding new objects, I had to do the same here:
 
detailNavController.navigationBar.barStyle =
//self.ownerTableViewModel.viewController.navigationController.navigationBar.barStyle;
UIBarStyleBlack;
 
 


on lines 1040-1042 of SCTableViewSection
  • fsauer
  • OFFLINE
  • Fresh Boarder
  • Posts: 14
  • Karma: 1

Re: nav bar color on a modal iPad detail view 1 year, 4 months ago #6

Setting "nav.navigationBar.barStyle = UIBarStyleBlack" should've fixed it, as STV's detail views automatically inherit their bar style from their parent view's bar style. I'll test your code and get back to you.
  • tarekskr
  • OFFLINE
  • Administrator
  • Posts: 2402
  • Karma: 72
  • Page:
  • 1
  • 2
Time to create page: 1.91 seconds