【发布时间】:2013-11-20 08:35:05
【问题描述】:
我有一个需要用户登录的视图。当用户尝试打开该视图但他未登录时,我将调用登录视图让他登录,完成后我将调用原始视图他打算看到的。
在 iPhone 上,当我将视图控制器推到那里时,这可以正常工作。
但是在我展示视图控制器的 iPad 上,这不起作用。它说正在解雇,不能显示新的控制器。代码如下:
- (void) buttonPressed
{
if (!userLoggedIn) { // userLoggedIn getter calls new screens of login if needed
return; // this is executed if user declined to login
}
MyViewController *temp = [[MyViewController alloc] init];
[self.navigationController presentViewController:temp animated:YES]; // this returns warning that dismissal in progress and does not work
}
对此我能做些什么?在 iPhone 上,我的所有逻辑都可以正常工作,但在 iPad 上却失败了。我在很多地方都使用它,完全重写代码并不好。
编辑:更多代码:
- (BOOL) userLoggedIn {
// code omitted
[centerController presentViewController:navController animated:YES completion:nil];
// code omitted
[centerController dismissViewController:navController animated:YES]; // setting to NO does not fix my problem
return YES;
}
编辑2: 这是 iPad 的代码。我已经删除了与 iPhone 相关的代码。它在 iPhone 上的作用 - 它使用推送而不是呈现控制器,在这种情况下一切正常。
【问题讨论】:
-
我认为您使用了两个 xib 一个用于 ipad 或一个用于 iphone 是否正确
-
更多代码会很有用,以便查看推送的内容和时间。
-
你已经用 modalviewcontroller 标记了这个。这里实际上涉及模态,还是只是使用了 UINavigationController?
-
查看您的额外代码(谢谢),我认为我发布的答案正是您所需要的。
-
@occulus presentViewController 是一种以模态方式呈现视图控制器的方法。 presentModalViewController 已被弃用,而是使用这个。
标签: ios objective-c ipad uinavigationcontroller modalviewcontroller