0

我必须通过检查两个特定视图控制器的视图来隐藏一个按钮,该视图是当前视图的后代。这是在应用程序进入前台时完成的。代码:

 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillEnterForeground) name:UIApplicationWillEnterForegroundNotification object:nil] ;


(void)applicationWillEnterForeground
{
   if(!([hrViewController.view isDescendantOfView:self.view] || [reportViewController.view isDescendantOfView:self.view]))

{
[self.theFavouriteButton setHidden:YES];
}

}

问题是,尽管进入前台时呈现的视图是 hrViewController.view 或 reportViewController.view,但控件到达了 if 条件内部并且隐藏了我的按钮。为什么会这样?

4

0 回答 0