3 回答
TA贡献1798条经验 获得超3个赞
if (viewController.isViewLoaded && viewController.view.window) { // viewController is visible}
if viewController.viewIfLoaded?.window != nil { // viewController is visible}
TA贡献1828条经验 获得超13个赞
以下是@progrmr的解决方案UIViewController类别:
// UIViewController+Additions.h
@interface UIViewController (Additions)
- (BOOL)isVisible;
@end
// UIViewController+Additions.m
#import "UIViewController+Additions.h"
@implementation UIViewController (Additions)
- (BOOL)isVisible {
return [self isViewLoaded] && self.view.window;
}
@end
TA贡献1836条经验 获得超3个赞
UISplitViewController
if(viewController.isViewLoaded && viewController.view.window) { //Always true for master view in split view controller}
- (void)viewDidDisappear:(BOOL)animated { [super viewDidDisappear:animated]; //We are now invisible self.visible = false;}- (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; //We are now visible self.visible = true;}
- 3 回答
- 0 关注
- 401 浏览
添加回答
举报