Tag: presentviewcontroller uiview hierarchy

iOS:警告“尝试呈现其视图不在窗口层次结构中的ViewController”

当我尝试在导航控制器上显示一个ActivityController时,我收到以下警告, Attempt to present <UIActivityViewController: 0x15be1d60> on <UINavigationController: 0x14608e80> whose view is not in the window hierarchy! 我试图通过下面的代码呈现视图控制器, UIActivityViewController * activityController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:applicationActivities]; activityController.excludedActivityTypes = excludeActivities; UIViewController *vc = self.view.window.rootViewController; [vc presentViewController: activityController animated: YES completion:nil]; [activityController setCompletionHandler:^(NSString *activityType, BOOL completed) { NSLog(@"completed"); }]; 这里怎么了?