【问题标题】:Modal UINavigationController Background Loading After Animation for PresentModalViewControllerPresentModalViewController 动画后的模态 UINavigationController 背景加载
【发布时间】:2011-09-29 22:04:38
【问题描述】:

我的模态 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 with presentModalViewController

UINavigationController and presentModalViewController

  • 这两种方法都适用于将 UINavigationController 用作其中包含 UIViewController 的模态屏幕的正确方法。

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

提前谢谢你!

J

【问题讨论】:

    标签: uiviewcontroller uinavigationcontroller background presentmodalviewcontroller loadview


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-03-31
      • 1970-01-01
      • 2014-06-06
      • 2021-04-30
      • 2010-12-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多