开发者

popover rotation

开发者 https://www.devze.com 2023-03-26 15:30 出处:网络
I created an iPad app and it works fine in landscape and portrait.Except when the app is rotated to landscape the popover is positioned incorrectly.Is there a way 开发者_C百科to add an if statement li

I created an iPad app and it works fine in landscape and portrait. Except when the app is rotated to landscape the popover is positioned incorrectly. Is there a way 开发者_C百科to add an if statement like pseudocode:

if in portrait CGRect
    use size S1 location L1
else if in landscape CGRect
    use size S2 location L2

My code:

UIPopoverController* popover = [[UIPopoverController alloc] initWithContentViewController:TweetFeed];
[popover setDelegate:self];
[popover presentPopoverFromRect:CGRectMake(401, 401, 220, 300) inView:self.view  permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];
[popover setPopoverContentSize:CGSizeMake(320, 150)];


Apple's documentation for UIPopoverController addresses this issue:

If the user rotates the device while a popover is visible, the popover controller hides the popover and then shows it again at the end of the rotation. The popover controller attempts to position the popover appropriately for you but you may have to present it again or hide it altogether in some cases. For example, when displayed from a bar button item, the popover controller automatically adjusts the position (and potentially the size) of the popover to account for changes to the position of the bar button item. However, if you remove the bar button item during the rotation, or if you presented the popover from a target rectangle in a view, the popover controller does not attempt to reposition the popover. In those cases, you must manually hide the popover or present it again from an appropriate new position. You can do this in the didRotateFromInterfaceOrientation: method of the view controller that you used to present the popover.

0

精彩评论

暂无评论...
验证码 换一张
取 消