我正在开发一个应用程序。在该应用程序中,我想提供一个带有选项的操作表。
我为操作表要求编写了以下代码。
UIActionSheet *actionSheet = [[UIActionSheet alloc]initWithTitle:nil delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:AALocalizedString(@"Capture Document", nil),AALocalizedString(@"Select Document", nil) ,AALocalizedString(@"Capture Photo", nil),AALocalizedString(@"Select Photo", nil),nil];
actionSheet.actionSheetStyle = UIActionSheetStyleDefault;
[actionSheet showInView:self.view];
actionSheet=nil;
它在iphone和ipad设备上运行良好,即iphone5,iphone5c,iphone5s,iphone4,iphone4s,ipod touch,ipad等。 但它不适用于iPad Mini。只显示取消按钮。
答案 0 :(得分:1)
在设置操作表的其他按钮标题时使用了AALocalizedString方法。确保方法是否给出字符串。如果它没有给出任何字符串,则操作表不显示其他按钮而不是取消按钮。或者一旦尝试以下代码。
UIActionSheet *actionSheet = [[UIActionSheet alloc]initWithTitle:nil delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Capture Document",@"Select Document" ,@"Capture Photo",@"Select Photo",nil]; actionSheet.actionSheetStyle = UIActionSheetStyleDefault; [actionSheet showInView:self.view]; actionSheet=nil;
答案 1 :(得分:0)
可能会帮到你,
UIAlertController *alertCV = [UIAlertController alertControllerWithTitle:@"Alert Title" message:nil preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *alertActn = [UIAlertAction actionWithTitle:@"Test1" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[alertCV dismissViewControllerAnimated:YES completion:nil];
}];
UIAlertAction *alertActn1 = [UIAlertAction actionWithTitle:@"Test2" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
[alertCV dismissViewControllerAnimated:YES completion:nil];
}];
[alertCV addAction:alertActn];
[alertCV addAction:alertActn1];
[self presentViewController:alertCV animated:YES completion:nil];