我在动画开始之前在模态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
任何帮助是极大的赞赏。我尝试了几种排列方式,但茫然不知所措。它是正确的顺序,但是显然我的代码没有达到完美的顺序。
先感谢您!
Ĵ
最佳答案
解决了问题-简单的错误。有一个背景设置,但使用的是“jpg”而不是“png”;)可悲的是,很多时间都浪费在了这个背景上。它总是给我带来错字。
关于uiviewcontroller - 动画后为PresentModalViewController加载模态UINavigationController背景,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7603904/