0
私はベースビューコントローラを持っており、すべてのビューコントローラがそれを継承しています。iOS別のビューコントローラにプッシュするget stuck
@interface BaseViewController() <UIGestureRecognizerDelegate>
@end
@implementation BaseViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.tabBarController.tabBar.translucent = NO;
self.navigationController.navigationBar.translucent = NO;
self.navigationController.interactivePopGestureRecognizer.delegate = self;
self.view.backgroundColor = [UIColor colorWithRed:0.95 green:0.95 blue:0.95 alpha:1];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:self.backButton];
self.navigationItem.backBarButtonItem.title = @"";
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (UIStatusBarStyle)preferredStatusBarStyle {
return UIStatusBarStyleDefault;
}
- (void) popToPreViewController {
[self.navigationController popViewControllerAnimated:YES];
}
#pragma mark - getter and setter
- (UIButton *) backButton {
if (!_backButton) {
_backButton = [[UIButton alloc] initWithFrame:CGRectMake(0.0, 0.0, 20.0, 20.0)];
[_backButton addTarget:self action:@selector(popToPreViewController) forControlEvents:UIControlEventTouchUpInside];
[_backButton setImage:[UIImage imageNamed:@"main_back"] forState:UIControlStateNormal];
_backButton.hidden = YES;
}
return _backButton;
}
@end
は時々動けなくなり、別のビューコントローラをプッシュしますが、アプリはcrash.Pressホームボタンせず、再びアプリを開いて、それは別のビューコントローラが表示されます。このbaseviewcontrollerに何か問題はありますか?
は「_backButton = [[UIButtonのalloc] initWithFrameバックボタンに設定されたRECT私は見ることができますが、ベース・ビュー・コントローラから子ビューコントローラを提示する方法 –
一つの問題は非常に小さいフレームであることをより多くのコードを提供します0.0、0.0、20.0、20.0)]; '。適切なユーザータップを受信するには少なくとも45x45である必要があります。ボタンインセットを使用してボタン画像を配置し、フレームを45x45以上に保持 –
@ aman.sood Thx! – jxdwinter