【问题标题】:How do I create a "delete" actionsheet in xcode?如何在 xcode 中创建“删除”操作表?
【发布时间】:2011-04-29 06:30:00
【问题描述】:

如何创建如下所示的删除确认?

【问题讨论】:

  • 在文档中查找 UIActionSheet。
  • 我已经编辑了你的标题,因为“popver”这个词指的是别的东西。 (请参阅 UIPopoverController 类参考。)

标签: ios cocoa-touch uiactionsheet confirmation


【解决方案1】:

这是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];

【讨论】:

    【解决方案2】:

    您需要使用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
        }
    }
    

    【讨论】:

      【解决方案3】:

      如果您想要与照片中显示的相同以及其他按钮,请使用下面的 UIActionSheet blog tutorial,如果您想要独立按钮,请按照下面的 SO 帖子进行操作

      How can I create a big, red UIButton with the iPhone SDK?

      【讨论】:

        【解决方案4】:

        使用 InterfaceBuilder(或 xCode4 中的等效编辑器)创建视图。编写您的视图控制器。然后使用 Core Animation 为视图设置动画以从下方滑入。

        【讨论】:

          猜你喜欢
          • 2013-07-15
          • 1970-01-01
          • 1970-01-01
          • 2023-03-23
          • 2022-07-06
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2016-01-08
          相关资源
          最近更新 更多