[英]In UIActionSheet the cancel button not showing for iphone?
在我的应用程序中,当我单击更改图像时,它要求UIActionsheet进行三项操作:拍照,从库中选择并取消。拍照,从库中进行选择正在显示,但取消没有显示出问题所在。 这是我的代码
- (void)viewDidLoad
{
[super viewDidLoad];
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Select Image from..."
delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Take Photo", @"Choose from library", nil];
actionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
actionSheet.actionSheetStyle = UIActionSheetStyleDefault;
[actionSheet showInView:self.view];
}
这是因为...我认为您使用的是默认的视图大小-Retina 4全屏作为视图大小...只需尝试从属性检查器将视图大小更改为Retina 3.5全屏... !!!
试试这个...
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Select Image from..."
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:@"Cancel"
otherButtonTitles:@"Take Photo", @"Choose from library", nil];
actionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
actionSheet.actionSheetStyle = UIActionSheetStyleDefault;
[actionSheet showInView:self.view];
您可能需要看一看在类参考中提供操作表的替代方法。 但是,您可能要尝试使用以下方法之一(如果有工具栏)
– showFromBarButtonItem:animated:
– showFromToolbar:
此外,使用以下内容
actionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
actionSheet.actionSheetStyle = UIActionSheetStyleDefault;
只会导致动作表样式为默认样式。
请参考此链接 。
您也可以参考以下代码,它可能对您有帮助:
(void)viewDidLoad
{
UIActionSheet * actionSheet = [[UIActionSheet alloc] initWithTitle:@"Select Image from..." delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Take Photo", @"Choose from library", nil];
[actionSheet showInView:self.view];
}
由于您的问题不在于您的代码。 也许您使用了错误的方法来显示UIActionSheet。
可以使用以下方法显示UIActionSheet:
– showFromTabBar:
– showFromToolbar:
– showInView:
– showFromBarButtonItem:animated:
– showFromRect:inView:animated:
由于使用的是TabBar,“取消”按钮也可能位于下方。 我也会测试。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.