【发布时间】:2011-04-29 06:30:00
【问题描述】:
如何创建如下所示的删除确认?
【问题讨论】:
-
在文档中查找 UIActionSheet。
-
我已经编辑了你的标题,因为“popver”这个词指的是别的东西。 (请参阅 UIPopoverController 类参考。)
标签: ios cocoa-touch uiactionsheet confirmation
如何创建如下所示的删除确认?
【问题讨论】:
标签: ios cocoa-touch uiactionsheet confirmation
这是UIActionSheet 的一个实例。红色按钮称为“破坏按钮”,黑色按钮称为“取消按钮”。
这是一个演示:
UIActionSheet *actSheet = [[UIActionSheet alloc] initWithTitle:@"The text to show on top. (Like the message about wiping the phone.)"delegate:nil cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Delete everything" otherButtonTitles:nil];
[actSheet ShowFromToolbar:self.toolbar];
[actSheet release];
【讨论】:
您需要使用UIActionSheet。
你可以像这样创建一个 ActionSheet
UIActionSheet *actionSheet = [[UIActionSheet alloc]
initWithTitle:@”YOUR_ACTION_SHEET_TITLE”
delegate:self
cancelButtonTitle:@”Cancel”
destructiveButtonTitle:@”Erase Iphone”
otherButtonTitles:nil];
[actionSheet showInView:self.view];
[actionSheet release];//If you are not using ARC
你需要实现UIActionSheetDelegate方法
- (void)actionSheet:(UIActionSheet *)actionSheet
clickedButtonAtIndex:(NSInteger)buttonIndex{
if (buttonIndex == 0){
//do your action
}else if(buttonIndex == 1){
// do your other action
}
}
【讨论】:
如果您想要与照片中显示的相同以及其他按钮,请使用下面的 UIActionSheet blog tutorial,如果您想要独立按钮,请按照下面的 SO 帖子进行操作
【讨论】:
使用 InterfaceBuilder(或 xCode4 中的等效编辑器)创建视图。编写您的视图控制器。然后使用 Core Animation 为视图设置动画以从下方滑入。
【讨论】: