在missModalViewControllerAnimated之后调用presentModalViewController有问题

发布于 2024-11-04 20:54:20 字数 608 浏览 1 评论 0原文

我有代码

- (void)matchmakerViewController:(GKMatchmakerViewController *)viewController didFindMatch:(GKMatch *)match
{
    [menuViewController dismissModalViewControllerAnimated:YES];
    [GameKitWrapper getSingleton].match = match;
    match.delegate = [GameKitWrapper getSingleton].remotePlayer;
    [menuViewController presentModalViewController:avatarSelectionViewController
                                      animated:YES];
}

,但我有一个问题,解雇正在起作用,但现在不起作用。当我将missModalViewControllerAnimated:YES更改为dismissModalViewControllerAnimated:NO时,它起作用了,但看起来不太好。

任何帮助表示赞赏。

I have the code

- (void)matchmakerViewController:(GKMatchmakerViewController *)viewController didFindMatch:(GKMatch *)match
{
    [menuViewController dismissModalViewControllerAnimated:YES];
    [GameKitWrapper getSingleton].match = match;
    match.delegate = [GameKitWrapper getSingleton].remotePlayer;
    [menuViewController presentModalViewController:avatarSelectionViewController
                                      animated:YES];
}

But I have the problem that the dismiss is working but not the present. When I changed dismissModalViewControllerAnimated:YES to dismissModalViewControllerAnimated:NO it worked but does not look nice.

Any help is appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

暗喜 2024-11-11 20:54:20

@adam 有正确的想法,但你不想等待一些任意的延迟。这是很脆弱的,因为动画可能需要任何时间才能完成。您想要等待前一个视图控制器实际完成关闭。根据我的经验,放置此内容的最佳位置是当前视图控制器的 viewDidAppear: 中。这将在你的模态完全消失后被调用。有关解决类似问题的一些示例代码,请参阅此问题

@adam has the right idea, but you don't want to wait for some arbitrary delay. That's fragile because it might take any amount of time for the animation to complete. You want to wait for the previous view controller to actually finish dismissing. The best place in my experience to put this is in your current view controller's viewDidAppear:. That will be called after your modal has completely gone away. See this question for some example code addressing a similar problem.

巷子口的你 2024-11-11 20:54:20

尝试等待一秒钟......

- (void)matchmakerViewController:(GKMatchmakerViewController *)viewController didFindMatch:(GKMatch *)match
{
    [menuViewController dismissModalViewControllerAnimated:YES];
    [GameKitWrapper getSingleton].match = match;
    match.delegate = [GameKitWrapper getSingleton].remotePlayer;
    [self performSelector:@selector(presentModal) withObject:nil afterDelay:1.0];
}

- (void)presentModal {   
    [menuViewController presentModalViewController:avatarSelectionViewController
                                          animated:YES];
}

Try waiting for a second....

- (void)matchmakerViewController:(GKMatchmakerViewController *)viewController didFindMatch:(GKMatch *)match
{
    [menuViewController dismissModalViewControllerAnimated:YES];
    [GameKitWrapper getSingleton].match = match;
    match.delegate = [GameKitWrapper getSingleton].remotePlayer;
    [self performSelector:@selector(presentModal) withObject:nil afterDelay:1.0];
}

- (void)presentModal {   
    [menuViewController presentModalViewController:avatarSelectionViewController
                                          animated:YES];
}
∞琼窗梦回ˉ 2024-11-11 20:54:20

尝试先拨打:

[menuViewController dismissModalViewControllerAnimated:NO];

在拨打:

[menuViewController presentModalViewController:avatarSelectionViewController
                    animated:YES];

Try calling:

[menuViewController dismissModalViewControllerAnimated:NO];

before calling:

[menuViewController presentModalViewController:avatarSelectionViewController
                    animated:YES];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文