0

私はしばらくの間アプリを構築しているので、これを尋ねるのはかなり恥ずかしいです。これまで、私は常にInterfaceBuilderを使用してビューなどを設定してきました。

これが私のloadViewです:

- (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

self.viewにsplashViewを追加します。

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 に答える