代码之家  ›  专栏  ›  技术社区  ›  pchap10k

如何在iPhone上创建多按钮确认?

  •  2
  • pchap10k  · 技术社区  · 16 年前

    在iPhone上,在日历应用程序中,当你按下“删除事件”按钮时,一个确认信息会从底部滑入。有人知道这方面的任何示例代码吗,或者它只是一个简短的视图,以自定义背景模式呈现?

    如果这是使用自定义视图制作的,您知道在哪里可以获得与日历应用程序中使用的背景图形相同的背景图形吗?

    提前谢谢!

    注意:我指的不是uialertview对话框,而是带有多个按钮的幻灯片确认。

    2 回复  |  直到 15 年前
        1
  •  7
  •   Mihir Mathuria    16 年前

    你要找的是uiactionsheet。

    下面是一些代码示例,让您开始使用:

    UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Save photo?" delegate:self cancelButtonTitle:@"No" destructiveButtonTitle:@"Yes" otherButtonTitles:nil];
     [actionSheet showInView:self.view];
     [actionSheet release];
    

    这将从底部滑入操作表。它有两个按钮。是和不是。

    当用户选择任何按钮时 actionSheet:didDismissWithButtonIndex: 方法被调用

    -(void) actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex{
    //your code here
    }
    

    您的控制器类必须订阅<uiActionSheetDelegate>协议

    希望这有帮助!

        2
  •  1
  •   Lachlan Roche    15 年前
    UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"title" delegate:self cancelButtonTitle:@"cancel"  destructiveButtonTitle:@"destructive" otherButtonTitles:@"other", nil];
    [actionSheet showInView:self.view];
    [actionSheet release];