2012-01-11 16 views
0

私はsplitViewControllerを持っています。これは詳細ですVCmasterViewが常に適切に表示/非表示されるとは限りません

-(void)viewDidLoad 
{ 
    self.masterIsVisible = YES; 
    //a botton in navigation bar to hide or show the master view. 
    [button addTarget:self action:@selector(showOrHideMasterView) 
    forControlEventsTouchUpInside] 
    //gesture control to swipe right or left to slide master view in and out. 
    [swiperight addTarget:self action:@selector(showMasterView)]; 
    [swipLeft addTarget:self action:@selector(hideMasterView)]; 
} 

-(void)showOrHideMasterView 
{ 
if (self.masterIsVisible) 
    [self hidemasterView]; self.masterIsVisible = NO; 
else 
    [self showMasterView]; self.masterIsVisible = YES; 
} 

-(void)hideMasterView 
{ 
    //hides master view by substracting masterview's width from its origin.x 
} 

-(void)showMasterView 
{ 
    //shows master View by adding masterview's width to its origin.x 
} 
- (BOOL)splitViewController:(UISplitViewController *)svc shouldHideViewController:  (UIViewController *)vc inOrientation:(UIInterfaceOrientation)orientation 
{ 
    return NO; 
} 

ほとんどすべてが意図したとおりに動作します。 問題:1つの向きで& &マスターが表示されていません。デバイスが方向を変更します。マスタービューが画面をスライドさせる代わりに、詳細ビューを別の方法で押しました。私はthatsを知っているので、フラグはYESの代わりにmasterIsVisible = NOに設定される。デバイスローテーションでフラグをYESに変更するにはどうすればよいですか。些細なことだが、理解できないようだ。

私はUIDeviceでデバイスの自動化を登録しようとしましたが、うまくいきませんでした。 BOOLはどのオリエンテーションでもYESです。リンゴの例ではこれを使用していますが、正しいアプローチではないようです。

+0

追加 - (BOOL)をsplitViewController:(UISplitViewController *)SVC shouldHideViewController:(のUIViewController *)のVC inOrientation:(UIInterfaceOrientation)配向 '? –

+1

私はそれを使用しています。私はそこに言及しませんでした。謝罪。このデリゲートメソッドではNOを返しました。 – yourAnswerIsAwesome

+0

そのメソッドに常に 'YES'を返すとどうなりますか? –

答えて

0

[OK]を、私は最終的にオリエンテーションの変更のためのフラグを正しく設定するために考え出しました。私は、なぜあなたはスプリットビューコントローラのデリゲートメソッド `使用していない次のような方法

-(void)willAnimateRotationToInterfaceOrientation: 
    (UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration 
{ 
if (toInterfaceOrientation == UIInterfaceOrientationPortrait) 
    self.masterIsVisible = NO; 
else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) 
    self.masterIsVisible = YES; 
else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) 
    self.masterIsVisible = YES; 
else if (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) 
    self.masterIsVisible = NO; 
} 
関連する問題