2011-06-21 13 views
0

私はしばらくの間、アプリケーションを構築していたので、これはかなり恥ずかしいです。過去に私はいつも私の意見などIBなしでビューを作成する

を設定するにInterface Builderを使用しました。ここに私loadViewメソッドです:ImageViewのが表示されないいくつかの理由

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

。エラーはありませんが、外観はありません。 UIViewが追加されますが、UIImageViewは追加されません。

私が言ったように、私は伝統的にこれをIBで行ってきましたので、私はプログラム的な方法にあまり慣れていません。

助けてください。

答えて

1

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

self.view = splashView; 

またはself.viewにあなたは、splashimageを追加します。この場合、あなたはUIViewのを必要としない - splashView:

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

申し訳ありませんが、それはタイプミスでした。私は 'self.view = splashView;'行を持ちましたが、まだ運がありません。私はあなたの他の解決策を試して、私はちょうど黒い画面を取得...画像に問題があることを示唆している。私は調査します –

+1

[UIImage imageNamed:@ "splash.jpg"] – CristiC

0

スプラッシュビューと呼ばれる新しいビューを作成し、ちょうどあなたのself.viewに画像ビューを追加しないようにしてください。

関連する問題