iphone - Multiple alertViews create error -


hello , afternoon, i'm having issues here, , honest, don't understand have create different alertviews same screen different messages, of these alerts have 1 button, there's 1 delete needs 2 buttons, thing that, since others have 1 button, when created 2 button screenview , added (void)alertview:(uialertview *)alertview clickedbuttonatindex:(nsinteger)buttonindex method, have problems

some code here

- (ibaction)saveinfo{ if (med.text.length ==0) {     uialertview *alertviewerror = [[uialertview alloc] initwithtitle:nslocalizedstring(@"error",@"")                                                         message:nslocalizedstring(@"empty1",@"")                                                         delegate:self                                                cancelbuttontitle:@"ok"                                                otherbuttontitles: nil];     [alertviewerror show];     [alertviewerror release]; } else if(medicamento.text.length >= 41){     [self lenghterror:40:nslocalizedstring(@"tf_med",@"")]; } else if (med.text.length ==0 || descripcion.text.length == 0) {     uialertview *alertviewerror = [[uialertview alloc] initwithtitle:nslocalizedstring(@"error",@"")                                                         message:nslocalizedstring(@"empty2",@"")                                                         delegate:self                                                cancelbuttontitle:@"ok"                                                otherbuttontitles: nil];     [alertviewerror show];     [alertviewerror release]; } else if (descripcion.text.length >= 41){     [self lenghterror:40:nslocalizedstring(@"tf_descripcion",@"")]; } else{     [self insertdictionary];     uialertview *alertviewacept = [[uialertview alloc] initwithtitle:@""                                                          message: nslocalizedstring(@"accept_msg",@"")                                                        delegate:self                                                cancelbuttontitle:@"ok"                                                otherbuttontitles: nil];     [alertviewacept show];     [alertviewacept release];     [self.navigationcontroller popviewcontrolleranimated:yes]; } 

}

- (ibaction)canceldata{ uialertview *alertviewcancel =  [[uialertview alloc] initwithtitle: nslocalizedstring(@"bt_delete_med",@"")                     message: nslocalizedstring(@"msg_delete_med",@"")                    delegate:self            cancelbuttontitle:@"ok"            otherbuttontitles: @"cancel", nil]; [alertviewcancel settag:999]; [alertviewcancel show]; [alertviewcancel release]; 

}

- (void)alertview:(uialertview *)alertview clickedbuttonatindex:(nsinteger)buttonindex { if (alertview.tag == 999) {     if(buttonindex==0){         [self.bayer_db_obj deleterowwithkeyvalue:[nsstring stringwithformat:@"%d",idmed] onkeyname:@"id_ctl_med" ontable:@"ctl_med"];         // code delete here         [self.navigationcontroller popviewcontrolleranimated:yes];     } } 

}

so, in first part, created alerts indicate user he/she making mistake, in second part, need confirmation before deletion, here, need 2 buttons, then, in 3rd part, have method been called, added tag alert avoid doing comparison in alerts, problem that, when show alertviewacept, takes previous view controller, , after click ok button (that cancelbuttontitle) app crashes without "error message"

so i'm not sure i'm doing wrong, please help

my guess problem set delegate alertviewacept, , right after showed alert, pop viewcontroller , delegate released, give error once button on alert view clicked.

you should this:

uialertview *alertviewacept = [[uialertview alloc] initwithtitle:@""                                                          message: nslocalizedstring(@"accept_msg",@"")                                                        delegate:nil                                                cancelbuttontitle:@"ok"                                                otherbuttontitles: nil]; 

even better, alerts have ok button, not need delegate. , in case not need tag.


Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -