0

アプリの最新の xCode および iOS 6 ビルド ターゲットの使用は 4.3 です。例として、私の最初のビューは 8 行のテーブルビューです。ユーザーが8行目を押すと、tableViewでもあるが4行の2番目のビューがプッシュされます。ユーザーが4行目を押すと、tableViewではなく標準ビューがプッシュされます。sharedManager は、方向と検出されたデバイス (iPhone または iPad) のいずれかのテーブルビューの行の高さを指定するシングルトンです。アプリはユニバーサルアプリです。

これらのすべてのビューで、viewWillAppear に以下があります

if([UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortrait || [UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationPortraitUpsideDown) {

    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {

        //iPhone Portrait
        self.tableView.rowHeight = [sharedManager contactRowHeight];

    }

    else{

        //iPad Portrait
        self.tableView.rowHeight = [sharedManager contactRowHeightIpad];
    }
    }

    if( [UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeLeft || [UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeRight){

    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {

        //iPhone Landscape
        self.tableView.rowHeight = [sharedManager contactRowHeightLandscape];

    }

    else{

        //iPad Landscape
        self.tableView.rowHeight = [sharedManager contactRowHeightLandscape_iPad];


    }
  }
 }

また、 willRotateToInterfaceOrientation で同じ向きの変更を処理します

  - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
  NSLog(@"willRotateToInterfaceOrientation: %d", toInterfaceOrientation);

  if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {

    NSString *iPhoneOrientation;
    switch(toInterfaceOrientation) {
        case UIInterfaceOrientationLandscapeRight:
            iPhoneOrientation = @"UIInterfaceOrientationLandscapeRight";
            self.tableView.rowHeight = [sharedManager contactRowHeightLandscape];
            break;

        case UIInterfaceOrientationLandscapeLeft:
            iPhoneOrientation = @"UIInterfaceOrientationLandscapeLeft";
            self.tableView.rowHeight = [sharedManager contactRowHeightLandscape];
            break;

        case UIInterfaceOrientationPortrait:
            iPhoneOrientation = @"UIInterfaceOrientationPortrait";
            self.tableView.rowHeight = [sharedManager contactRowHeight];
            break;

        case UIInterfaceOrientationPortraitUpsideDown:
            iPhoneOrientation = @"UIInterfaceOrientationPortraitUpsideDown";
            self.tableView.rowHeight = [sharedManager contactRowHeight];
            break;

        default:
            iPhoneOrientation = @"Invalid orientation";
    }
    NSLog(@"willRotateToInterfaceOrientation: %@", iPhoneOrientation);

 }

 else{

    NSString *iPadOrientation;
    switch(toInterfaceOrientation) {
        case UIInterfaceOrientationLandscapeRight:
            iPadOrientation = @"UIInterfaceOrientationLandscapeRight";
            self.tableView.rowHeight = [sharedManager contactRowHeightLandscape_iPad];
            break;

        case UIInterfaceOrientationLandscapeLeft:
            iPadOrientation = @"UIInterfaceOrientationLandscapeLeft";
            self.tableView.rowHeight = [sharedManager contactRowHeightLandscape_iPad];
            break;

        case UIInterfaceOrientationPortrait:
            iPadOrientation = @"UIInterfaceOrientationPortrait";
            self.tableView.rowHeight = [sharedManager contactRowHeightIpad];
            break;

        case UIInterfaceOrientationPortraitUpsideDown:
            iPadOrientation = @"UIInterfaceOrientationPortraitUpsideDown";
            self.tableView.rowHeight = [sharedManager contactRowHeightIpad];
            break;

        default:
            iPadOrientation = @"Invalid orientation";
    }
    NSLog(@"willRotateToInterfaceOrientation: %@", iPadOrientation);

 }

}

現在、私が抱えている問題は、ビュー 1 - 3 からどの方向でも問題なく動作しますが、ビュー 3 を横向きに回転させてからビュー 2 と 1 に戻ると、回転コードが横向きで機能せず、正しく表示されないことです。ビュー1から3に移動するときに証明されるように、すべての要素に正しいレイアウトフレームを指定しますか?

また、問題の特定に役立つ可能性があるのは、最初のビューでナビゲーション バーを非表示にし、ビュー 2 と 3 で再表示することです。これが役立つかどうかはわかりません。

4

0 に答える 0