iPhone - 平滑显示2个连续模态视图控制器

发布于 2024-10-14 08:57:17 字数 1857 浏览 4 评论 0原文

我正在寻找一种方法,能够一个接一个地显示一个模态视图控制器,并在第一个消失时使第二个出现。

问题是,在第一个 modalviewcontroller 内完成的解除调用适用于两者,而 SecondController 永远不会显示。

将第一次解雇放在父调用之前或之后不会改变任何内容。 如果第一次解雇设置为 animate= NO,则一切正常。但我需要动画。

我计划这样做,但问题是第一个 modalviewcontroller 内完成的解雇调用适用于两者,而 SecondController 永远不会显示。

我不明白为什么,因为每个模式视图都有自己的导航控制器,所以它们不应该发生冲突。

我尝试了另一种方法,在 0.5 秒后用 NSTimer 显示第二个模态视图,但它并不令人满意:当第一个模态视图完全消失时,第二个模态视图出现。一点也不流畅...如果我将延迟设置为小于 0.5 秒,则第二个模态视图永远不会显示。而使用这样的定时器来做这似乎并不是一个好的编码方式。

Main.m

- (void) entry {

    FirstController *nextWindow = [[FirstController alloc] initWithNibName:@"theNIB" bundle:nil];

    nextWindow.caller = self;

    UINavigationController* navController = [[UINavigationController alloc] initWithRootViewController:nextWindow];

    [self.navigationController presentModalViewController:navController animated:YES];

    [nextWindow release];
    [navController release];
}


- (void) thingsDoneInFirstModalController:(OBJECT)returnValue retval2:(OBJECT2)returnValue2 {
    [self display2ndController];
}

- (void) display2ndController {

    SecondController *nextWindow;

    nextWindow = [[SecondController alloc] initWithNibName:@"NIB2" bundle:nil];

    UINavigationController* navController = [[UINavigationController alloc] initWithRootViewController:nextWindow];
    [self.navigationController presentModalViewController:navController animated:YES];
    [navController release];
    [nextWindow release];
}

1st ModalViewController.m

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    [self.navigationController dismissModalViewControllerAnimated:YES];
    [self.caller thingsDoneInFirstModalController:theResult retval2:someMoreResult];
}

您是否知道一种方法可以实现这一点(使第二个视图出现,而第一个视图消失),例如一些代码?

谢谢。

I'm searching a way to be able to display one modal view controller after another one, and make the second appear while the first is disapearing.

The problem is that the dismiss call that is done inside the first modalviewcontroller applies to both and SecondController is never shown.

Putting the first dismiss before or after the parent call does not change anything.
If first dismiss is set wih animate= NO, everything works fine. But I need the animation.

I planned to do that this way, but the problem is that the dismiss call that is done inside the first modalviewcontroller applies to both and SecondController is never shown.

I don't understand why because each modal view has its own navigationcontrollers, so they shouldn't collide.

I tried another way by showing the second modal view with a NSTimer after 0.5 sec, but it's not satisfying : the second appears when the first has completely disapeared. Not smooth at all... If I set the delay less than 0.5 sec, the second modal view never shows up. And using such a timer to make this does not seem to be a good way of coding.

Main.m

- (void) entry {

    FirstController *nextWindow = [[FirstController alloc] initWithNibName:@"theNIB" bundle:nil];

    nextWindow.caller = self;

    UINavigationController* navController = [[UINavigationController alloc] initWithRootViewController:nextWindow];

    [self.navigationController presentModalViewController:navController animated:YES];

    [nextWindow release];
    [navController release];
}


- (void) thingsDoneInFirstModalController:(OBJECT)returnValue retval2:(OBJECT2)returnValue2 {
    [self display2ndController];
}

- (void) display2ndController {

    SecondController *nextWindow;

    nextWindow = [[SecondController alloc] initWithNibName:@"NIB2" bundle:nil];

    UINavigationController* navController = [[UINavigationController alloc] initWithRootViewController:nextWindow];
    [self.navigationController presentModalViewController:navController animated:YES];
    [navController release];
    [nextWindow release];
}

1st ModalViewController.m

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    [self.navigationController dismissModalViewControllerAnimated:YES];
    [self.caller thingsDoneInFirstModalController:theResult retval2:someMoreResult];
}

Do you know a way to make this possible (make the second view appears while the first one is disappearing), with some code for example ?

Thank you.

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

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

发布评论

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

评论(1

想念有你 2024-10-21 08:57:17

尝试创建一些虚拟 ViewController,并使用它来展示您的第二个视图控制器。

Try creating some dummy ViewController, and present your second one using it.

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