我有一个 iPad 应用程序,它有一个从按钮调用的操作表。我将 showFromRect 用于 actionSheet,所以它看起来像一个 popOver。当应用程序第一次启动时,actionSheet 永远不会显示在正确的位置,直到设备至少旋转一次之后。设备旋转后,actionSheet 位于正确的位置。我的代码如下。
-(IBAction)showMenu
{
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Copy To The Clipboard" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Term & Definition",@"Term",@"Definition", nil];
UIDevice *thisDevice = [UIDevice currentDevice];
CGRect myImageRect;
if(thisDevice.orientation==UIDeviceOrientationPortrait){myImageRect = CGRectMake(300.0f, 950.0f, 320.0f, 175.0f);NSLog(@"P");} //Portait Mode
else if(thisDevice.orientation==UIDeviceOrientationPortraitUpsideDown){myImageRect = CGRectMake(300.0f, 950.0f, 320.0f, 175.0f);NSLog(@"PUD");}//Portait Mode UpsideDown
else if(thisDevice.orientation==UIDeviceOrientationLandscapeLeft){myImageRect = CGRectMake(300.0f, 700.0f, 320.0f, 175.0f);NSLog(@"LL");}//Landscape Mode Left
else if(thisDevice.orientation==UIDeviceOrientationLandscapeRight){myImageRect = CGRectMake(300.0f, 700.0f, 320.0f, 175.0f);NSLog(@"LR");}//Landscape Mode Right
[actionSheet showFromRect:myImageRect inView:self.view animated:YES];
[actionSheet release];
}
任何帮助将不胜感激。