直接把 presentViewController 方法替换为此方法即可
- (void)rootViewController:(UIViewController *) vc {
UIViewController *topRootViewController = [[UIApplication sharedApplication] keyWindow].rootViewController;
// 在这里加一个这个样式的循环
while (topRootViewController.presentedViewController) {
// 这里固定写法
topRootViewController = topRootViewController.presentedViewController;
}
// 然后再进行present操作
[topRootViewController presentViewController:vc animated:YES completion:nil];
}
本文介绍了一种在iOS开发中将presentViewController方法替换为自定义方法的技巧,通过循环找到顶层视图控制器并进行present操作。
1万+

被折叠的 条评论
为什么被折叠?



