Is there a way for the Top View Controller in ECSlidingViewController to know when the sidebar menu has been dismissed?

为君一笑 提交于 2019-12-11 09:44:51

问题


Is there a way for the Top View Controller in ECSlidingViewController to know when the sidebar menu has been dismissed, or when it is about to become the focus? i.e. a sort of viewWillAppear equivalent for ECSlidingViewController. I have a refreshcontrol in my top view controller that starts misbehaving after the sidebar is shown, so I am trying to figure out where I can call endRefreshing on the refreshControl so that the wierdness goes away. Putting it in viewWillAppear doesn't work. Thanks!


回答1:


Since ECSlidingViewController v2.0 does not have notifications, I was able to solve this in the following way. In the sidebar menu, in ViewWillDisappear I call a new category method on UIViewController called "willGetFocus." Whenever my topViewController needs to know when it's about to get focus I override willGetFocus in that view Controller like so:

In sidebar menu:

 -(void) viewWillDisappear:(BOOL)animated
 {
     [super viewWillDisappear:animated];
     UINavigationController* topViewController =    
        ((UINavigationController*)self.slidingViewController.topViewController);
     [topViewController.visibleViewController willGetFocus];
 }

In Top View Controller:

-(void) willGetFocus {

    [self.refreshControl endRefreshing];
}

New Category:

@interface UIViewController (KnowsFocus)

-(void) willGetFocus;

@end

@implementation UIViewController (KnowsFocus)

-(void) willGetFocus {

}
@end


来源:https://stackoverflow.com/questions/26130272/is-there-a-way-for-the-top-view-controller-in-ecslidingviewcontroller-to-know-wh

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!