3

我在动画开始之前显示的模态 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 的模态屏幕的正确方法。

非常感谢任何帮助。我已经尝试了几种排列并且不知所措。它有正确的顺序,但我的代码显然没有得到完美的顺序。

先感谢您!

Ĵ

4

1 回答 1

1

解决了这个问题 - 简单的错误。有一个背景设置,但使用的是“jpg”而不是“png”;)可悲的是,很多时间浪费在这个上。它总是让我犯错。

于 2011-10-17T15:53:43.983 回答