Created
February 18, 2014 09:05
-
-
Save shuizhongyueming/9067243 to your computer and use it in GitHub Desktop.
如何使用UIActionSheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 定义一个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