// UIActionSheet这个控件很常用,和UIAlertView类似,先附图
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"请选择你喜欢的水果" delegate:self cancelButtonTitle:@"取消"
destructiveButtonTitle:@"确定" // 这个按钮的会以红色显示,在次设置一些重要的选项 otherButtonTitles:@"苹果", @"葡萄", @"大枣儿", @"哈密瓜", @"杏儿", @"荔枝", nil];
actionSheet.delegate = self; // 设置代理为本身actionSheet.actionSheetStyle = UIActionSheetStyleAutomatic; // 设置样式
[actionSheet showInView:self.view]; // 设置UIAcitonSheet在哪个view上显示
[actionSheet release], actionSheet = nil;
// 代理方法
#pragma mark - 重写-----UIActionSheetDelegate协议中的方法
#pragma mark 判断您点击的是哪个按钮
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
NSLog(@"点击了序号为 %d 的按钮", buttonIndex);
}
#pragma mark 将要隐藏
- (void)actionSheet:(UIActionSheet *)actionSheet willDismissWithButtonIndex:(NSInteger)buttonIndex {
NSLog(@"点击序号为 %d 的按钮 <<span style="line-height: normal; font-family: 'Heiti SC Light'; ">将要> 使UIActionSheet隐藏", buttonIndex);
}
#pragma mark 已经隐藏
- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex {
NSLog(@"点击序号为 %d 的按钮 <<span style="line-height: normal; font-family: 'Heiti SC Light'; ">已经> 使UIActionSheet隐藏", buttonIndex);}
#pragma mark 不明白这个方法,希望懂的告诉下
- (void)actionSheetCancel:(UIActionSheet *)actionSheet {
}