Skip to content

Instantly share code, notes, and snippets.

@shuizhongyueming
Created February 18, 2014 09:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shuizhongyueming/9067243 to your computer and use it in GitHub Desktop.
Save shuizhongyueming/9067243 to your computer and use it in GitHub Desktop.
如何使用UIActionSheet
// 定义一个UIActionSheet
UIActionSheet *actionSheet = [[UIActionSheet alloc]
initWithTitle:@"Are you sure?"
delegate:self
cancelButtonTitle:@"No Way!"
destructiveButtonTitle:@"Yes, I'm Sure"
// 其他按钮,没有直接写nil
otherButtonTitles:@"Foo",@"Bar",nil];
// 放到View中显示
[actionSheet showInView:self.view];
// 当前view的controller即self,实现UIActionSheetDelegate方法
-(void)actionSheet:(UIActionSheet *)actionSheet
didDismissWithButtonIndex:(NSInteger)buttonIndex
{
if(buttonIndex != [actionSheet cancelButtonIndex])
{
// do something
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment