vendredi 31 juillet 2015

Not able to add UIBarButton programatically to UINavigationBar ( UITabbarController)

I have a UITabbarController and connected to 5 UIViewController, and i have added UIBarButton to UINavigationbar in ViewController1.

But When i run that application am not able to see the UIBarButton in navigationbar, i can see only one plain navigationbar.

This is the code to update UINavigationBar.

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;

This was working without UITabbarController, but when i added UITabbarController to my storyboard its not working pls help me..

Aucun commentaire:

Enregistrer un commentaire