在视图控制器(A)中,另一个视图控制器(B)将显示为模态VC。
设置以下属性VC(B)并将其显示在关键窗口中的topViewController不起作用。
B.providesPresentationContextTransitionStyle = YES;
B.definesPresentationContext = YES;
[B setModalPresentationStyle:UIModalPresentationOverCurrentContext];
- (void)presentViewControllerInKeyWindow:(UIViewController*)viewController animated:(BOOL)animated completion:(void (^)(void))completion
{
UIViewController *topViewController = [UIApplication sharedApplication].keyWindow.rootViewController;
if(topViewController.presentedViewController != nil) {
topViewController = [UIApplication sharedApplication].keyWindow.rootViewController.presentedViewController;
while(topViewController.presentedViewController) {
topViewController = topViewController.presentedViewController;
}
}
[topViewController presentViewController:viewController animated:animated completion:completion];
}
没有显示alertcontroller而是抛出错误。错误表示VC已经出现。
答案 0 :(得分:1)
检查您是否有任何名为inputView或inputAccessoryView的属性。如果是,则更改这些名称并尝试。