我是编程新手,正如主题所暗示的那样iOS
,我有一个问题。UIAlertViews
我有一个按钮可以删除SQLite DB
. 此按钮调用 aUIAlertview
以在删除记录时为用户提供一些不同的选项。
- (IBAction)deleteFunction:(id)sender {
UIAlertView *delChoice = [[UIAlertView alloc] initWithTitle:@"Select from below." message:@"WARNING!:You are about to remove records. This is irreversible." delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Delete Completed jobs",@"Delete All records",@"Select items to delete.", nil];
[delChoice show];
}
这是下一个方法
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
NSString *title =[alertView buttonTitleAtIndex:buttonIndex];
if([title isEqualToString:@"Delete All records"]){
[database executeUpdate:@"delete from issues"];
if([database lastErrorCode]!=NULL){
UIAlertView *unconfirm = [[UIAlertView alloc]initWithTitle:@"Failure!" message:@"Something went wrong. Try one more time." delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil];
[unconfirm show];
}else {
UIAlertView *confirm = [[UIAlertView alloc]initWithTitle:@"Success!" message:@"All records have been removed." delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil];
[confirm show];
}
}
这不是完整的方法。我的问题是,在嵌套的 uialertview(取消确认和确认)中,如果我决定添加“otherButtonTitles”,我该如何回应?我是否使用相同的主要方法做同样的事情?
另外,如果有更好的方法可以做到这一点,我将不胜感激!