2012-01-09 7 views
0

私はポートレートモードとランドスケープモードの双方向サポートを備えたアプリケーションを開発しています。ios5のオリエンテーションサポート

私は以下のios4.3とで正常に動作し

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{ 
self.view.frame = CGRectMake(0,0,1024,768); 
} 

その中にビューフレームと資産の大きさを変更することによって、これを達成されました。

私がXcode4.2とios5.0で実行しようとすると、シミュレータの向きが明確ではありません。私はポートレートからランドスケープビューに変更したときに画面にフィットしない(フレームサイズが実際のランドスケープフレームサイズよりも小さい)ことを意味します。

なぜ起こっているのですか?

多くのおかげで、 アビ

答えて

2

ある姿勢の変化が実際に行われたときにフレームを適用しますxcode4.2とiOS 5はオリエンテーションの変更に迅速な対応があり、他のビューやコントロールは改善されているので、あなたのためには機能しませんので、didRotateFromInterfaceOrientation o r willRotateFromInterfaceOrientationこれで正常に動作します。

- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    //support for all orientation change 
    return YES; 
} 
- (void) didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation 
{ 
// in iOS statusBarOrientation is correct than all other orientation changes 
if(UIDeviceOrientationIsLandscape([UIApplication sharedApplication].statusBarOrientation)) 
    self.view.frame = CGRectMake(0,0,1024,768); 
else 
    self.view.frame = CGRectMake(0,0,768,1024); 

} 
+0

@ balakrishnanありがとうございます。:-) – Avi

0

は を設定するプロパティの配向のサポートを確認し、この1

てみてくださいこれは、ステータスバーに

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation{ 

if(interfaceOrientation == UIInterfaceOrientationPortrait){ 
    self.view.frame = CGRectMake(0,0,768,1004); 
} 
else{ 
    self.view.frame = CGRectMake(0,0,1024,748); 
} 
} 
+0

試してみてください...高さが変更されています。 – Avi

+0

viewDidLoadコードを表示できますか? – Hiren

+0

xibを使用してビューをデザインしました。 viewdidLoadに何も書き込まないようにします。そのちょうど - (void)viewDidLoad { [super viewDidLoad]; } – Avi