I am now using UINavigationController in my application .I have added a button to the view of this navigationcontroller so that this button appears on top of the navigationBar .
The problem is when I hide the navigationBar and also hide the button and show them again ,the NavigationBar appears on top of the button .
Can anyone solve this issue ?
@interface MyNavigationController : UINavigationController<UINavigationControllerDelegate>
{
UIButton *btnBack ;
}
-(id)initWithRootViewController:(UIViewController *)rootViewController
{
self = [super initWithRootViewController:rootViewController];
if (self)
{
self.delegate = self ;
self.navigationBar.barStyle = UIBarStyleBlack;
//btnBack
UIImageView *gameImage = [[UIImageView alloc] initWithFrame:CGRectMake(1, 1, 32, 27)];
self.btnBack = [UIButton buttonWithType:UIButtonTypeCustom];
self.btnBack.frame = CGRectMake(10, 5.0, 60, 30);
[self.btnBack setBackgroundImage:[UIImage imageNamed:@"backicon.png"] forState: UIControlStateNormal];
[self.btnBack addTarget:self action:@selector(back:) forControlEvents:UIControlEventTouchUpInside];
[self.btnBack addSubview: gameImage];
[self.view addSubview:self.btnBack];
}
return self ;
}
-(void)hideNavigationItems
{
[self setNavigationBarHidden:YES animated:YES];
self.btnBack.hidden = YES ;
}
-(void)showNavigationItems
{
self.navigationBarHidden = NO;
self.btnBack.hidden = NO ;
}
As said in comment, try: