iPhone - 平滑显示2个连续模态视图控制器
我正在寻找一种方法,能够一个接一个地显示一个模态视图控制器,并在第一个消失时使第二个出现。
问题是,在第一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试创建一些虚拟 ViewController,并使用它来展示您的第二个视图控制器。
Try creating some dummy ViewController, and present your second one using it.