2012-03-08 12 views
2

私はこのコードを持っている:UIPopoverが再配置されますが、間違った場所に

:だから今、私はそれが私のポップオーバーを再配置し、デバイスを回転させるが、とき

- (void)repositionPopOver { 

    if (self.targetButton) { 

     [self.popoverController presentPopoverFromRect:self.targetButton.frame 
               inView:self.view 
           permittedArrowDirections:UIPopoverArrowDirectionAny 
               animated:YES]; 
    } 
} 

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { 
    // Reposition the Popover after rotation 
    [self repositionPopOver]; 
} 

を間違った場所で

http://i.minus.com/jbxYSIHSJhV8yC.png

赤い長方形が回転しながら、targetButton

+0

didRotateが実際に呼び出されていることを確認します。 repositionPopOverで、targetButtonとpopoverControllerがnilでないことを確認します。 – Anna

+0

渡す "inView"パラメータには注意してください。あなたのボタンはself.viewに存在しますか? – cocoakomali

答えて

0

で、あなたが最初のポップオーバーを解雇しようとすると、再できないことに注意してくださいそれを作成し、方向に基づいて表示します。 { if([YourPopUpViewControllerOBject] .isPopOverVisible) { [[YourPopUpViewControllerOBject] dismissPopoverAnimated:YES]; } //オリエンテーションに基づいてPopOverを表示するコード }

関連する問題