我在UIActionSheet上有一个简单的问题!如何设置UIActionsheet的高度?我尝试过setFrame和setBounds,但都不起作用。我正在使用下面的行动手册:
NSString *title = UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation) ? @"\n\n\n\n\n\n\n\n\n" : @"\n\n\n\n\n\n\n\n\n\n\n\n" ;
UIActionSheet *actionSheet = [[UIActionSheet alloc]
initWithTitle:[NSString stringWithFormat:@"%@%@", title, NSLocalizedString(@"", @"")]
delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Button1",@"Button2", nil];
[actionSheet setTag: 1];
//[actionSheet setBounds:CGRectMake(0,0,320,150)];
//[actionSheet showFromRect:CGRectMake(0,0,100,50) inView: self.parentViewController.tabBarController.view animated:YES];
// [actionSheet setFrame:CGRectMake(0, 30, 320, 30)];
actionSheet.actionSheetStyle = UIActionSheetStyleAutomatic;
[actionSheet showInView:self.parentViewController.tabBarController.view];
actionSheet = nil;我这里的问题是动作页的高度等于当前视图的高度。我想根据UIActionSheet的内容自动调整高度。
提前谢谢你,
发布于 2012-04-20 08:04:24
UIActionSheet的默认行为是自动调整到它的内容大小。你不应该直接设置frame。
你会看到动作页占据了如此多的空间,因为你在标题中插入了一堆换行符,迫使标题标签占据了比它应该占据的垂直空间更多的空间。如果你不想动作单那么高,就不要把标题改成那样。
https://stackoverflow.com/questions/10238179
复制相似问题