ECSlidingViewController中的“顶视图控制器"是否有办法知道边栏菜单何时被关闭? [英] Is there a way for the Top View Controller in ECSlidingViewController to know when the sidebar menu has been dismissed?

查看:64
本文介绍了ECSlidingViewController中的“顶视图控制器"是否有办法知道边栏菜单何时被关闭?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ECSlidingViewController中的Top View Controller是否有办法知道何时关闭侧边栏菜单或何时将其变为焦点?即ECSlidingViewController的等效viewWillAppear.我的顶视图控制器中有一个refreshcontrol,在显示侧边栏后它开始出现异常,因此我试图找出在refreshControl上可以在何处调用endRefreshing的方法,以便消除烦恼.将其放在viewWillAppear中不起作用.谢谢!

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!

推荐答案

由于ECSlidingViewController v2.0没有通知,因此我可以通过以下方式解决此问题.在侧边栏菜单中,在ViewWillDisappear中,我在UIViewController上调用了一个名为"willGetFocus"的新类别方法.每当我的topViewController需要知道何时要获得焦点时,我都会在该View Controller中覆盖willGetFocus,如下所示:

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:

在侧边栏菜单中:

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

在顶视图控制器中:

-(void) willGetFocus {

    [self.refreshControl endRefreshing];
}

新类别:

@interface UIViewController (KnowsFocus)

-(void) willGetFocus;

@end

@implementation UIViewController (KnowsFocus)

-(void) willGetFocus {

}
@end

这篇关于ECSlidingViewController中的“顶视图控制器"是否有办法知道边栏菜单何时被关闭?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆