0
votes

I have an issue With UINavigationBar , when i add UIButton over there and when i run the application i can see one extra UINaviagtionBar overlay on top of my UINavigationBar.

Please help

The structure is like

UITabbarController -> UINavigationController -->UIViewController

I have attached screen shots link

Run time[![[1]][1]][1]

Xcode enter image description here

[navigationcontroller->viewcontroller screen][3]

Code

ViewDidAppear()

UIImage *myImage = [UIImage imageNamed:@"filter.png"];
UIButton *myButton = [UIButton buttonWithType:UIButtonTypeCustom];
[myButton setImage:myImage forState:UIControlStateNormal];
myButton.showsTouchWhenHighlighted = YES;
myButton.frame = CGRectMake(0.0, 0.0,25,25);
[myButton addTarget:self action:@selector(refreshSection) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithCustomView:myButton];
self.navigationItem.leftBarButtonItem = rightButton;

UIImage *myImage1 = [UIImage imageNamed:@"Contacts.png"];
UIButton *myButton1 = [UIButton buttonWithType:UIButtonTypeCustom];
[myButton1 setImage:myImage1 forState:UIControlStateNormal];
myButton1.showsTouchWhenHighlighted = YES;
myButton1.frame = CGRectMake(0.0, 0.0,30,30);

[myButton1 addTarget:self action:@selector(profile) forControlEvents:UIControlEventTouchUpInside];

UIBarButtonItem *rightButton1 = [[UIBarButtonItem alloc] initWithCustomView:myButton1];
[self.navigationItem setRightBarButtonItems:[NSArray arrayWithObjects:rightButton1, nil]];

full screen storyboard

2
Please post a better screenshot of your xcode project. Have you embedded your view controller in a Navigation Contoller? Or are you manually adding a navigation bar into the View controller? - Gurtej Singh
yes, embedded with uinavigation controller - naveen kumar
See if this thread is of any help: stackoverflow.com/questions/11199227/… - Gurtej Singh
ok sure let me check - naveen kumar

2 Answers

0
votes

I think code is correct just set contentMode property.

[[myButton imageView] setContentMode: UIViewContentModeScaleAspectFit];

Same for other buttons.

0
votes

Go to your root navigation controller, select the navigation bar and under the Attributes Inspector, make sure you have:

  1. Default style,
  2. Translucent option enabled,
  3. Default bar tint.