2010-12-22 6 views
1

2つのビュー(firstviewcontrollerとsecondviewcontroller)を持つタブバーアプリケーションを使い始めました.2番目のビューコントローラには背景画像はありませんが、最初のビューコントローラはありません。iPadオリエンテーションの問題

私はprotraitとimageの2つの画像を持っています。私がしたいのは、向きが変わるたびに背景画像を読み込むだけです。私はすべてのオリエンテーションをサポートしたい。ここ

は私のviewDidLoadメソッド

-(void)viewDidLoad 
{ 
    imgview=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bgportrait.png"]]; 
    [imgview setFrame:CGRectMake(0, 0, 768, 1024)]; 
    [self.view addSubview:imgview]; 
    [self.view sendSubviewToBack:imgview]; 
    [imgview release]; 
} 

(BOOL)shouldAutorotateToInterfaceOrientationである:(UIInterfaceOrientation)interfaceOrientation {のNSLog(@ "shouldrotateで"); return YES;それがもしループのいずれかに行くことはありません、それはログを印刷doesntのwillRotateToInterfaceOrientationで }

(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 
{ 
    if (toInterfaceOrientation == (UIInterfaceOrientationPortrait || UIInterfaceOrientationPortraitUpsideDown)) 
{ 
    NSLog(@"in portrait"); 
} 
else if (toInterfaceOrientation == (UIInterfaceOrientationLandscapeLeft || UIInterfaceOrientationLandscapeRight)) 
{ 
    NSLog(@"in landscape"); 
} 

} 

そのそれらのいずれかに方向性を一致しない理由を、私はわかりません。私はちょうどfirstviewcontrollerに適切な背景イメージを設定したい。私はそれが非常にシンプルでなければならないことを知っていますが、私はそれを正しく得ることができません。

+0

のようにあなたの状態をチェックし、あなたのコードをフォーマットしてください。あなたの質問を編集している間、エディタの直上にコードを適切に書式設定する '{}'記号があります。 – darioo

答えて

2

この

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 
{ 
    if(toInterfaceOrientation==UIInterfaceOrientationPortrait || 
     toInterfaceOrientation==UIInterfaceOrientationPortraitUpsideDown) 
    { 
     NSLog(@"in portrait"); 
    } 
    else 
    { 
     NSLog(@"in landscape"); 
    } 
} 
+0

はい、今度はifループに入ります。今私はこれをした – Rajashekar

+1

あなたは答えを受け入れることができます – iPrabu