2012-03-19 15 views
0

私たちは背景画像を設定するベースクラスを使用しています。私は別のUIViewControllerのための私のスーパークラスとしてこれを使用したいが、私はそれをどのように行うか、backgoundを使用しない場合viewDidLoadのサブクラスで異なる背景イメージを設定する

UIImage* image = [UIImage imageNamed:@"App_Background.png"]; 
UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; 
imageView.contentMode = UIViewContentModeScaleAspectFill; 
CGRect bounds = self.view.bounds; 
int offset = 0; 

imageView.frame = CGRectMake(0, bounds.size.height - image.size.height + offset, image.size.width, image.size.height); 
imageView.autoresizingMask = UIViewAutoresizingFlexibleTopMargin; 
imageView.tag = BACKGROUND_TAG; 
[self.view insertSubview:imageView atIndex:0]; // insert it behind all other views in NIB 

self.background = [imageView autorelease]; // cleanup 

:このコードは次のようになりますか?私は私のサブクラス 'viewDidLoadでこれを行うことができると思った:

UIView *theBackgroundView = [self.view viewWithTag:BACKGROUND_TAG ]; 
theBackgroundView = nil; 

しかし、それは動作しません。何かご意見は?ありがとう。

答えて

0

[super viewDidLoad]に最初にと電話してください。次に[[self.view viewWithTag: BACKGROUND_TAG] removeFromSuperview]を実行します。

関連する問題