开发者

UINavigationController not popping view on back button

I have a UINavigationController. I've got a UIViewController that I've pushed onto the stack using pushViewCo开发者_StackOverflowntroller. The previous view controller has a backBarButtonItem simply titled "Cancel."

While the new view animates in correctly, when I tap Cancel, the navigation bar animates as if the view was popped, but the new view doesn't go away. Do I need to implement a delegate somewhere?


Try this,

First Create a UIButton then Create one UIBarButtonItem with Custom view, considering UIButton as custom view for UIBarButtonItem.

Consider button to target event for popping view controller.

UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(0, 0, 35, 35);
[button setImage:[UIImage imageNamed:@"dots.png"] forState:UIControlStateNormal];
[button addTarget:self action:@selector(backBarButton:) forControlEvents:UIControlEventTouchUpInside];

UIBarButtonItem *backBarButton = [[UIBarButtonItem alloc] initWithCustomView:button];

self.navigationItem.leftBarButtonItem = backBarButton;

- (void)backBarButton:(id)sender {
NSLog(@"%s", __FUNCTION__);
self.navigationController.navigationBarHidden = YES;
[self.navigationController popViewControllerAnimated:YES];
}

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜