我在动画开始之前显示的模态 UIViewController 中的背景有问题。我有一个简单的 UINavigationController 加载 UIViewController。然后我通过从下方向上滑动的 presentModalViewController 调用呈现 UINavigationController。在 UIViewController 的 loadView 方法中,我设置了标准的 self.view 并创建了一个背景 UIImageView。此背景加载,但仅在模态动画完成之后。我以前做过很多次这类事情,记得曾经遇到过这个问题,但我一生都找不到我的“神奇”解决方案是什么。
我的代码如下:
PhotoVideoViewController *photo = [[PhotoVideoViewController alloc] init];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:photo];
NSLog(@"start present modal view controller");
[self.navigationController presentModalViewController:nav animated:YES];
[photo release];
[nav release];
PhotoVideoViewController 加载视图:
- (void)loadView {
UIView *myview = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
self.view = myview;
[myview release];
NSLog(@"background loading");
UIImageView *background = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"background-main.png"]];
background.frame = CGRectMake(0, -45, 320, 480);
[self.view addSubview:background];
[background release];
}
在“后台加载”日志显示之前,日志中显示“启动当前模式视图控制器” ,这显然告诉我有问题。我试图把[照片发布]; 在presentModalViewController之前,但它不能解决问题。
我也在这里完成了我的研究,其他帖子都没有回答我的问题:
UINavigationController 与 presentModalViewController
UINavigationController 和 presentModalViewController
- 这两者都适用于将 UINavigationController 用作其中包含 UIViewController 的模态屏幕的正确方法。
非常感谢任何帮助。我已经尝试了几种排列并且不知所措。它有正确的顺序,但我的代码显然没有得到完美的顺序。
先感谢您!
Ĵ