uiviewcontroller - 动画后为PresentModalViewController加载模态UINavigationController背景

标签 uiviewcontroller uinavigationcontroller background presentmodalviewcontroller loadview

我在动画开始之前在模态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 loadView:
- (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];
}

在日志中显示“开始当前模式 View Controller ”之前,在显示“后台加载”日志之前,这显然告诉我出了什么问题。我试图把[照片发布]放进去;在presentModalViewController之前,但不能解决问题。

我也在这里进行了研究,其他任何帖子都没有回答我的问题:

UINavigationController with presentModalViewController

UINavigationController and presentModalViewController
  • 两者都适用于将UINavigationController用作内部带有UIViewController的模式屏幕的正确方法。

  • 任何帮助是极大的赞赏。我尝试了几种排列方式,但茫然不知所措。它是正确的顺序,但是显然我的代码没有达到完美的顺序。

    先感谢您!

    Ĵ

    最佳答案

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

    关于uiviewcontroller - 动画后为PresentModalViewController加载模态UINavigationController背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7603904/

    相关文章:

    ios - Swift 4 UIWebView 视频全屏约束错误

    objective-c - 如何/是否模拟 UINavigationController pushToViewController 方法

    android - 带有背景和居中文本的 TextView

    cocoa-touch - 像 UIViews 一样在其他 UIViewControllers 中使用 "nest"UIViewControllers 是否明智?

    ios - 新的 View Controller 出现然后消失在 CCScene 后面

    ios - 如何为特定的 UIViewController 设置默认返回 UINavigationItem?

    swift - 为什么 hidesBottomBarWhenPushed 在不是 Root View Controller 时不起作用?

    ios - popViewController :animated: not working in iOS 9

    css - 背景幻灯片,但文本滚动

    android ftp上传已停止错误