2011-11-11 8 views
0

私は、ビューの向きを変更する機能を適用しているアプリケーションがありますが、向きを変更すると次の画面に進み、デバイスをイメージの右側に回転させるとギャップが表示されます: enter image description hereどのように画面からギャップを削除しますか?

私はviewcontroller.mにこのコードを使用:

-(void) viewWillAppear:(BOOL)animated{ 
    UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation]; 

    [self willAnimateRotationToInterfaceOrientation:orientation duration:0]; 


} 

-(void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 
{ 
    if(toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) 
    { 

     lgo_imag.frame=CGRectMake(0, 0, 320, 44); 
     btn_settings.frame=CGRectMake(238, 3, 72, 37); 
     btn_alarm_activity.frame=CGRectMake(125, 10, 70, 85); 
     btn_alarm_screen.frame=CGRectMake(48, 210, 225, 55); 
     btn_routine_screen.frame=CGRectMake(48, 275, 225, 55); 
     btn_view_info.frame=CGRectMake(48, 340, 225, 55); 
     lable_alarm_value.frame=CGRectMake(25, 100, 270, 81); 
     scroll_view.frame=CGRectMake(0, 44, 320, 416); 
     scroll_view.contentSize=CGSizeMake(320 ,416); 

    } 
    else if(toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) 
    { 


     lgo_imag.frame=CGRectMake(0, 0, 480, 44); 
     btn_settings.frame=CGRectMake(398, 3, 72, 37); 
     btn_alarm_activity.frame=CGRectMake(205, 10, 70, 85); 
     btn_alarm_screen.frame=CGRectMake(128, 210, 225, 55); 
     btn_routine_screen.frame=CGRectMake(128, 275, 225, 55); 
     btn_view_info.frame=CGRectMake(128, 340, 225, 55); 
     lable_alarm_value.frame=CGRectMake(125, 100, 270, 81); 
     scroll_view.frame=CGRectMake(0, 44, 480, 320); 
     scroll_view.contentSize=CGSizeMake(480 ,470); 
    } 


} 
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    // Overriden to allow any orientation. 
    return YES; 
} 

どのようにその問題を解決しますか?

+1

あなたのサイズを再計算する必要があるように私には見えます。ランドスケープビューは確かに480 x 470ではありません。 –

+0

紫はおそらくコントローラのビューの背景色ですか?自動サイズ設定のフラグは何を設定していますか?どのような状況でもwillAnimateを明示的に呼び出す必要はありません。 – Tommy

答えて

0

ビューフレームに+20を追加します。これは、ステータスバーのスペースを含まないために発生します。

+0

どこでどのように使用できますか? – ios

+0

コンテンツ表示中の風景モード – DivineDesert

0

のオートスタイルには、以下のプロパティを使用できます。しかし、それを使用する際には注意してください。オートスケールするコントロールのプロパティのみを変更してください。

enter image description here

EDIT

私はあなたが方法を変更する向きであなたのコードを入れていないと考え、このリンクiPhone SDK: Orientation (Landscape and Portrait views)を通過してください。このリンクは間違いなくあなたを導くでしょう。

姿勢変化検出のためにこのメソッドを使用し..

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    // Return YES for supported orientations 
    return (interfaceOrientation == UIInterfaceOrientationLandscape); 
} 
+0

私はそれを行うが、私のappkliationに影響しません – ios

+0

私の編集セクションを参照してください。 – DShah

+0

それはまた動作しない、まだギャップがあります。 – ios

関連する問題