2017-04-11 31 views
0

最近、私は次のviewControllerにpushViewControllerを押したときに奇妙な問題が発生しました。 なぜそれは奇妙な質問だと思いますか?必ずしも現れるとは限りません(発生確率は低い)。表示されたら、次のviewControllerは画面上のナビゲーションバーのみを表示しますが、私はまだrootViewControllerを見ることができますが、反応なしでそれに触れます(PopGestureは有効です)。問題が発生しましたpushViewController

enter image description here

#pragram mark - method of pushing 
- (void)clickToAccout { 

    if (![self countTotalSelectedNumber]) { 
     [SVProgressHUD showInfoWithStatus:@"没有被选择的商品"]; 
     return; 
    } 

    CSCreatOrderViewController *creatOrderVC = [[CSCreatOrderViewController alloc] init]; 
    creatOrderVC.totalPrice = [self countTotalPrice]; 
    creatOrderVC.goods = [self selectedGoods]; 

    [self.navigationController pushViewController:creatOrderVC animated:YES]; 
} 

#pragma mark - chlid class of navgationController 

- (void)viewDidLoad { 
    [super viewDidLoad]; 

    self.navigationBar.tintColor = [UIColor whiteColor]; 
} 

- (UIStatusBarStyle)preferredStatusBarStyle { 
    return _barStyle; 
} 

- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{ 
    if (self.viewControllers.count > 0) { 
     viewController.hidesBottomBarWhenPushed = YES; 
     [SVProgressHUD dismiss]; 
    } 

    [super pushViewController:viewController animated:animated]; 
} 

- (UIViewController *)popViewControllerAnimated:(BOOL)animated { 
    [SVProgressHUD dismiss]; 

    return [super popViewControllerAnimated:animated]; 
} 

- (void)didReceiveMemoryWarning { 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 


#pragma mark - tabBarController 

- (void)viewDidLoad { 
    [super viewDidLoad]; 

    CSTabBar *tabBar = [[CSTabBar alloc] init]; 
    [self setValue:tabBar forKey:@"tabBar"]; 

    [self.tabBar setTintColor:[UIColor cz_colorWithHex:0Xec5151]]; 

    [self addChildViewControllerWithTitle:@"首页" imageName:@"home" controllerName:@"CSHomeViewController"]; 
    [self addChildViewControllerWithTitle:@"分类" imageName:@"classify" controllerName:@"CSClassifyViewController"]; 
    [self addChildViewControllerWithTitle:@"查询" imageName:@"search" controllerName:@"CSSearchViewController"]; 
    [self addChildViewControllerWithTitle:@"购物车" imageName:@"cart" controllerName:@"CSShoppingCartViewController"]; 
    [self addChildViewControllerWithTitle:@"我的" imageName:@"mine" controllerName:@"CSMineViewController"]; 

    self.selectedIndex = 0; 
} 

- (void)addChildViewControllerWithTitle:(NSString *)title imageName:(NSString *)imageName controllerName:(NSString *)controllerName { 

    Class cls = NSClassFromString(controllerName); 

    UIViewController *vc = [[cls alloc] init]; 
    vc.title = title; 
    [vc.tabBarItem setImage:[UIImage imageNamed:[NSString stringWithFormat:@"%@",imageName]]]; 
    [vc.tabBarItem setSelectedImage:[UIImage imageNamed:[NSString stringWithFormat:@"%@_selected",imageName]]]; 
    vc.tabBarItem.title = title; 

    CSNavigationController *nav = [[CSNavigationController alloc] initWithRootViewController:vc]; 
    [self addChildViewController:nav]; 
} 


#pragma mark - base viewController 
- (void)viewDidLoad { 
    [super viewDidLoad]; 

    self.view.backgroundColor = [UIColor whiteColor]; 

    [self setupNavItem]; 

    self.navigationController.interactivePopGestureRecognizer.enabled = YES; 
    self.navigationController.interactivePopGestureRecognizer.delegate = self; 

    _indciatorView = [[CSIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; 

    UIWindow *keyW = [UIApplication sharedApplication].keyWindow; 
    [keyW addSubview:_indciatorView]; 

    [_indciatorView mas_makeConstraints:^(MASConstraintMaker *make) { 
     make.center.equalTo(keyW); 
    }]; 
} 


- (void)setupNavItem { 

    UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)]; 
    button.imageEdgeInsets = UIEdgeInsetsMake(9, 0, 9, 29); 
    [button setImage:[UIImage imageNamed:@"left"] forState:UIControlStateNormal]; 
    [button addTarget:self action:@selector(clickToDismiss) forControlEvents:UIControlEventTouchUpInside]; 

    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:button]; 
} 

- (void)clickToDismiss { 
    [self.navigationController popViewControllerAnimated:YES]; 
} 

- (void)didReceiveMemoryWarning { 
    [super didReceiveMemoryWarning]; 
} 
+0

一部のコード内であなたの投稿を編集できますか? –

+0

OK、数分待って – wakakaJP

+0

この問題はすべてのルートビューコントローラで発生する可能性がありますので、ベースビューコントローラに問題がありますが見つかりませんでした – wakakaJP

答えて

0

私はあなたが

[self.navigationController pushViewController:viewController animated:animated]; 

と同じポップ

[super popViewControllerAnimated:animated]; 

[super pushViewController:viewController animated:animated]; 

を変更すべきだと思います

[self.navigationController popViewControllerAnimated:animated]; 
+0

コードがUINavgationControllerの私のパッケージサブクラス私はあなたが私の問題を解決することができないと思っていますが、私はこの方向に努力します、あなたの助けをありがとう。 – wakakaJP

0

に私はXcodeののキャッシュをクリアし、この場合は表示されません。たぶん私はこのケースを引き起こした3番目のlibをインポートしました。しかし、私が尋ねたように、必ずしも現れるとは限りません(発生確率は低い)。それで、それがうまくいったことを願って。

+0

この問題はもう一度起こりました。私はジェスチャーレコグナイザー – wakakaJP

関連する問題