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

pch*_*10k 2 iphone sdk uikit uialertview uiactionsheet

在iPhone上,当您按下"删除事件"按钮时,在日历应用程序中,确认从底部滑入.有没有人知道这个的任何示例代码,还是只是一个简短的视图呈现模式与自定义背景?

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

提前致谢!

注意:我不是在谈论UIAlertView对话框,而是带有多个按钮的滑入式确认.

Mih*_*ria 7

您正在寻找UIActionSheet.

以下是一些代码示例,可帮助您入门:

UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Save photo?" delegate:self cancelButtonTitle:@"No" destructiveButtonTitle:@"Yes" otherButtonTitles:nil];
 [actionSheet showInView:self.view];
 [actionSheet release];
Run Code Online (Sandbox Code Playgroud)

这将从底部滑入操作表.它有2个按钮.是和否.

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

-(void) actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex{
//your code here
}
Run Code Online (Sandbox Code Playgroud)

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

希望这可以帮助!