[英]Determine if instance of UIViewController subclass exists
如何检查继承UIViewController的所有活动对象的列表?
我想知道MyViewController
的实例是否存在。 理想情况下,我可以在UIApplicationDelegate
的回调中获取此信息(例如application:didReceiveRemoteNotification :)。
我已经尝试记录像navigationController.viewControllers
这样的东西没有运气。 我还在modalViewController
上尝试过topViewController
和modalViewController
属性。
如果你知道你的rootViewController是一个UINavigationController的事实,你可以遍历viewcontrollers数组并测试它的类类型
BOOL success = NO;
NSArray *viewControllersArray = self.navigationController.viewControllers;
for (id vc in viewControllersArray)
{
if ([vc isKindOfClass:[MyViewController class]])
success = YES; // Found it!
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.