唐巧的博客

封装同步的UIActionSheet

问题

做 iOS 开发的同学想必都用过 UIActionSheet。UIActionSheet 可以弹出一个选择列表,让用户选择列表中的某一项操作。使用 UIActionSheet 非常简单,以下是一个简单的示例代码:

- (void)someButtonClicked {
UIActionSheet * sheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"ddd" destructiveButtonTitle:@"aaa" otherButtonTitles:@"bbb", @"ccc", @"ddd", nil];
sheet.destructiveButtonIndex = 1;
[sheet showInView:self.view];
}

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
int result = buttonIndex;
NSLog(@"result = %d", result);
}

但我个人在使用时,感觉 UIActionSheet 有以下 2 个问题: