我有这个代码:
UIActionSheet *actionSheet = [[[UIActionSheet alloc]
initWithTitle:@"Illustrations"
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:nil
otherButtonTitles: @"ABC", @"XYZ",
nil] autorelease];
UIImage *image = // whatever, snip
if (image != nil)
{
[actionSheet addButtonWithTitle:@"LMNOP"];
}
Run Code Online (Sandbox Code Playgroud)
它可以有条件地添加我的LMNOP按钮.
...取消按钮后.
如何使用条件按钮构建我的操作表?可悲的是,我做不到:
UIActionSheet *actionSheet = [[[UIActionSheet alloc]
// ... etc.
otherButtonTitles: someMutableArray
// ... etc.
Run Code Online (Sandbox Code Playgroud)
因为那肯定会有所帮助.
有任何想法吗?
谢谢!

我想知道如何用这样的按钮创建一个popover.
回答:
UIActionSheet * actionSheet = [[UIActionSheet alloc] initWithTitle: nil
delegate: self
cancelButtonTitle: nil
destructiveButtonTitle: nil
otherButtonTitles: @"Take Photo",
@"Choose Existing Photo", nil];
[actionSheet showFromRect: button.frame inView: button.superview animated: YES];
Run Code Online (Sandbox Code Playgroud)
委托对象类中的其他位置......
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0) {
// take photo...
}
else if (buttonIndex == 1) {
// choose existing photo...
}
}
Run Code Online (Sandbox Code Playgroud) uiactionsheet ipad uipopovercontroller ios uialertcontroller
其他一些人已经提出了这个问题,但它从来没有被回答过.问题似乎微不足道,但Apple的文档或其他地方尚未解决.
我正在使用以下showInView方法呈现我的UIActionSheet实例:
UIActionSheet *myActionSheet = [[UIActionSheet alloc] initWithTitle:@"Test" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Destroy" otherButtonTitles:@"One", @"Two", nil];
[myActionSheet showInView:self.view];
Run Code Online (Sandbox Code Playgroud)
UIActionSheet在中心以任何方向呈现,但是当我旋转iPad时,它会在top-right或中看到bottom-left(取决于方向是否更改为纵向或横向).
如果将自动调整大小设置为UIViewAutoresizingFlexibleBottomMargin和UIViewAutoresizingFlexibleRightMargin,这是大多数视图元素的默认autoresizingMask值,则会出现这种情况,因此我尝试通过调用setAutoresizingMaskUIActionSheet实例上的方法来重置该值.
[myActionSheet setAutoresizingMask:UIViewAutoresizingNone];
Run Code Online (Sandbox Code Playgroud)
但是,Autoresizing Mask的这个或任何其他价值都无法实现任何改变.
有没有解决这个问题的方法?我宁愿不诉诸于解雇UIActionSheet轮换并重新展示它 - 原则上这种方法似乎是不必要的.
是否可以创建一个ActionSheet在这个图像之间的两个按钮之间有标签的?

现在真的需要这个.谁能帮我?谢谢.
Apple的UIActionSheet文档让我感到困惑.首先,在iPad人机界面指南中,它说:
要了解有关在代码中使用操作表的更多信息,请参阅"iPad编程指南"中的"使用弹出窗口显示内容".
但是在"使用弹出窗口显示内容"部分中,它根本没有提到动作表!我在这里错过了什么吗?
我的主要问题是:在iPad上,UIPopoverController和UIActionSheet有什么区别?如果UIActionSheet自动出现在UIPopoverController中,是否有任何理由使用UIActionSheet?我看到它的委托和按钮的自动创建如何减少代码行数,但从可用性POV来看,是否存在差异?
此外,显示带动画的actionSheet根本不起作用.它的外观和行为与没有动画时显示的actionSheet完全相同(这与我刚刚使用UIPopoverController并且根本没有使用actionSheet完全相同).这是我的代码:
UIActionSheet *action = [[UIActionSheet alloc] initWithTitle:@"An unsaved property already exists. You must assign a name to this property before creating a new property. Would you like to:"
delegate:self
cancelButtonTitle:nil
destructiveButtonTitle:@"Overwrite"
otherButtonTitles:@"Open unsaved property", nil];
[action showFromRect:CGRectMake(0, 0, 200, 200) inView:self.mainSplitViewController.view animated:NO];
Run Code Online (Sandbox Code Playgroud)
我如何获得一个看起来像Apple文档中的示例动画actionSheet的actionSheet(从地图应用程序中,您向联系人添加位置)?
我可能最终会使用警报而不是弹出窗口或actionSheet,但理解这一点仍然有用.
谢谢!
objective-c uialertview uiactionsheet ipad uipopovercontroller
我创造了一个 UIActionSheet
UIActionSheet * action = [[UIActionSheet alloc]initWithTitle:@""
delegate:self
cancelButtonTitle: @"cancel"
destructiveButtonTitle: @"OK"
otherButtonTitles: nil];
[action showInView:self.view];
[action release];
Run Code Online (Sandbox Code Playgroud)
在取消按钮的事件中,UIActionSheet我想要触发一个事件UIBarButtonItem,这在我看来.
我的问题是如何在UIActionSheet委托方法中触发按钮事件(不触摸按钮)
在iPad上,可以使用-showFromBarButtonItem:animated:来显示UIActionSheet.这很方便,因为它将UIPopoverController包装在操作表周围,并将弹出框的箭头指向传入的UIBarButtonItem.
但是,此调用将UIBarButtomItem的工具栏添加到直通视图列表中 - 这并不总是可取的.并且,如果没有指向UIPopoverController的指针,则无法将其他视图添加到直通列表中.
有没有人知道获得指向弹出控制器的指针的制裁方法?
提前致谢.
在我的应用程序的iPhone版本中,我有UIDatePicker一个UIActionSheet.看来是对的.我现在正在设置应用程序的iPad版本,UIActionSheet在iPad上查看时显示为空白空白框.
这是我正在使用的代码:
UIDatePicker *datePickerView = [[UIDatePicker alloc] init];
datePickerView.datePickerMode = UIDatePickerModeDate;
self.dateActionSheet = [[UIActionSheet alloc] initWithTitle:@"Choose a Follow-up Date"
delegate:self cancelButtonTitle:nil
destructiveButtonTitle:nil otherButtonTitles:@"Done", nil];
[self.dateActionSheet showInView:self.view];
[self.dateActionSheet addSubview:datePickerView];
[self.dateActionSheet sendSubviewToBack:datePickerView];
[self.dateActionSheet setBounds:CGRectMake(0,0,320, 500)];
CGRect pickerRect = datePickerView.bounds;
pickerRect.origin.y = -95;
datePickerView.bounds = pickerRect;
Run Code Online (Sandbox Code Playgroud) 基本上我想让用户点击文本字段,它会显示一个填充的选择器视图而不是键盘.这也需要一个带有完成按钮的工具栏以及Im假设.我目前将字段设置为输出和操作,而不是更多.我还有一个代码中的动作表,用于当用户提交内容时,如果这对于可能使用动作表也有任何不同.
我尝试研究这个主题,但99%的主题是使用datepickers而不是pickerviews(或非常旧的代码).
这是一张图片,供参考.

在iPad上,新的ios 7 UIActionSheet没有正确显示,有很多按钮.
在滚动时不清除UIActionSheet的背景.按钮似乎在后台UIActionSheet中冻结.
我的代码:
UIActionSheet *popupQuery = [[UIActionSheet alloc];
for (int i=0; i<[ParamAllList count]; i++)
{
NSMutableDictionary *Param = [ParamAllList objectAtIndex:i];
[popupQuery addButtonWithTitle:[Param valueForKey:@"name"]];
[[[popupQuery valueForKey:@"_buttons"] objectAtIndex:[[popupQuery valueForKey:@"_buttons"] count]-1] setImage:[UIImage imageNamed:@"add40icon.png"] forState:UIControlStateNormal];
}
popupQuery.actionSheetStyle = UIActionSheetStyleAutomatic;
[popupQuery showFromRect:Button_Settings.frame inView:Button_Settings.superview animated:YES];
Run Code Online (Sandbox Code Playgroud) uiactionsheet ×10
ipad ×5
ios ×2
iphone ×2
objective-c ×2
autorotate ×1
button ×1
dynamic ×1
events ×1
ios5 ×1
ios7 ×1
uialertview ×1
uidatepicker ×1
uikeyboard ×1
uipickerview ×1