- (IBAction)showActionSheet:(UIButton *)sender {
UIActionSheet *actionSheet = [[UIActionSheet alloc]initWithTitle:@"Select the operation to proceed?"delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Delete" otherButtonTitles:@"Create", @"Update", @"Duplicate", nil] ;
[actionSheet showInView:self.view];
}
如果未选择任何内容,则自动选择取消;基于计时器,例如5秒然后动臂取消?
UIActionSheet而不是UIAlertController,因为我想要制作iOS 7.1兼容的二进制文件
答案 0 :(得分:3)
[self.actionSheet dismissWithClickedButtonIndex:[self.actionSheet cancelButtonIndex]
animated:YES];
或者例如:
- (IBAction)showActionSheet:(UIButton *)sender {
UIActionSheet *actionSheet = [[UIActionSheet alloc]initWithTitle:@"Select the operation to proceed?"delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:@"Delete" otherButtonTitles:@"Create", @"Update", @"Duplicate", nil] ;
[actionSheet showInView:self.view];
[self performSelector:@selector(dismissActionSheet:) withObject:actionSheet afterDelay:5.0];
}
-(void)dismissActionSheet:(UIActionSheet *)actionSheet{
if(actionSheet){
[actionSheet dismissWithClickedButtonIndex:[actionSheet cancelButtonIndex]
}
}