简体   繁体   English

ECSlidingViewController中的Top View Controller是否有办法知道边栏菜单何时被关闭?

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

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? ECSlidingViewController中的“顶视图控制器”是否有办法知道何时关闭侧边栏菜单或何时将其变为焦点? ie a sort of viewWillAppear equivalent for ECSlidingViewController. 即,一种等效于ECSlidingViewController的viewWillAppear。 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. 我的顶视图控制器中有一个refreshcontrol,在显示侧边栏后它开始出现异常,因此我试图找出在refreshControl上可以在何处调用endRefreshing的方法,以便消除烦恼。 Putting it in viewWillAppear doesn't work. 将其放在viewWillAppear中不起作用。 Thanks! 谢谢!

Since ECSlidingViewController v2.0 does not have notifications, I was able to solve this in the following way. 由于ECSlidingViewController v2.0没有通知,因此我可以通过以下方式解决此问题。 In the sidebar menu, in ViewWillDisappear I call a new category method on UIViewController called "willGetFocus." 在侧边栏菜单中的ViewWillDisappear中,我在UIViewController上调用了一个新的类别方法,称为“ willGetFocus”。 Whenever my topViewController needs to know when it's about to get focus I override willGetFocus in that view Controller like so: 每当我的topViewController需要知道何时要获得焦点时,我都会在该View Controller中覆盖willGetFocus,如下所示:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ECSlidingViewController-如何知道菜单何时显示? - ECSlidingViewController - How do you know when the menu has been shown? iOS - 了解模态视图何时被解除 - iOS - Know when modal view has been dismissed 模态视图控制器被关闭后如何调用函数 - How to call a function when a Modal View Controller has been dismissed ECSlidingViewController:显示左菜单时模糊视图控制器 - ECSlidingViewController: blur view controller when displaying left menu 有没有办法知道UIViewController是否已经以模态方式呈现和解散? - Is there a way to know if a UIViewController has been presented and dismissed modally ? 视图控制器被解雇后如何显示警报 - How to present an alert after view controller has been dismissed 如何检查视图 controller 是否已在 Swift 中被取消 - How to check if a view controller has been dismissed in Swift 知道何时使用手势关闭拆分视图控制器的主对象 - Know when split view controller's master is dismissed with a gesture 从详细信息视图控制器返回时,SideBar菜单不起作用 - SideBar Menu is not working when it is coming back from the detail View Controller ECSlidingViewController滑回主视图控制器时回调? - ECSlidingViewController Callback when sliding back to main view controller?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM