2011-02-27 10 views
2

私はポートレートモードでテーブルビューを表示するUITableViewControlerがあります。現在の回転モーダルビュー

私はiPhoneを回転させると、私は横長モードでモーダルビューを表示したいと思います。 tableViewで

は、私が使用します。

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); 
} 

また、本モーダルビュー処理する:私は、モーダルビューは、次の

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation duration:(NSTimeInterval)duration { 
     if((interfaceOrientation == UIInterfaceOrientationLandscapeRight) || (interfaceOrientation == UIInterfaceOrientationLandscapeLeft)) 
     { 
      NSLog(@"Push page view"); 
      PagingViewController *s = [[PagingViewController alloc] initWithNibName:@"PagingView" bundle:nil]; 
      s.hidesBottomBarWhenPushed = YES; 

      [self presentModalViewController:s animated:YES]; 
      [s release]; 
     } 
} 

を:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { 
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); 
} 

とTOそれを自分自身のモーダル表示を却下する、私は行う:

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation duration:(NSTimeInterval)duration { 
    if (interfaceOrientation == UIInterfaceOrientationPortrait) 
    { 
     NSLog(@"Dismiss my self"); 
     [self.parentViewController dismissModalViewControllerAnimated:YES]; 
    } 
} 

これは2回の動作方法です。 iPhoneをPortraitモードからLandscapeモードに3回回転させると、不正なアクセスエラーが発生します。

私にエラーが表示されるのはわかりません。 誰かがショットを気にしますか?

+0

不正アクセスエラーはどの行で発生しますか? (あなたは、デバッガでこれを見ることができます。) –

+0

私は2番目のモーダルを解除した後、UITableViewControllerで何かをしようとするたびに。だから私はUITableViewController何とか解雇されると思います。 – esbenr

+0

私は、3.0と似たようなやり方であらゆる種類の問題を抱えていました。既知のバグと競合状態のように見えます。最後に、変更を監視するためにデバイス通知を使用しました。たとえば、これを参照してください:http://stackoverflow.com/questions/1500060/view-controller-not-getting-shouldautorotatetointerfaceorientation-messages-on – petert

答えて

0

私が考えることができる最も簡単な方法は、-shouldAutorotate ...を実装し、モーダルビューを閉じて回転を中止するためにNOを返すことです。多分、並行性の問題を避けるには十分でしょう。この提案があなたの好みでない場合は、NSNotificationCenterをご覧ください。