【问题标题】:UIAlertController not showing on a modal UIViewController?UIAlertController 未显示在模态 UIViewController 上?
【发布时间】:2018-06-06 05:55:11
【问题描述】:

在 viewcontroller(A) 中,另一个 viewcontroller(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 已经出现。

【问题讨论】:

    标签: ios uialertcontroller presentviewcontroller


    【解决方案1】:

    检查您是否有任何名为 inputView 或 inputAccessoryView 的属性。如果是,请更改这些名称并尝试。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-09
      • 1970-01-01
      • 2015-12-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多