0

问这个很尴尬,因为我已经构建应用程序有一段时间了。过去我一直使用 Interface Builder 来设置我的视图等。

这是我的加载视图:

- (void)loadView {
    UIView *splashView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
    splashView.backgroundColor = [UIColor clearColor];

    UIImageView *splashImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[[NSBundle mainBundle]pathForResource:@"splash" ofType:@"jpg"]]];
    splashImage.frame = [splashView bounds];
    [splashView addSubview:splashImage];

    self.view = splashView;
}

由于某种原因,imageView 没有出现。没有错误,只是没有外观。UIView 已添加,但 UIImageView 未添加。

就像我说的,我传统上是用 IB 做的,所以我对编程方法不太熟悉。

任何帮助表示赞赏。

4

2 回答 2

1

将 splashView 添加到 self.view:

self.view = splashView;

或将您的 splashImage 添加到 self.view 中。在这种情况下,您不需要 UIView - splashView:

UIImageView *splashImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[[NSBundle mainBundle]pathForResource:@"splash" ofType:@"jpg"]]];
splashImage.frame = [splashView bounds];
[self.view addSubview:splashImage];
于 2011-06-21T15:15:12.723 回答
0

尝试不要创建一个名为启动视图的新视图,只需将图像视图添加到您的 self.view 中。

于 2011-06-21T15:27:33.767 回答