标签:style blog color for div sp 代码 log on
AlertView的show方法执行后,后面的代码会继续运行,而不会等待用户按键结束再走,这样,如果把弹出的代码写在一个BOOL函数里,没等用户确认直接返回NO就惨了,解决方法:
1 - (BOOL)beforeBackButtonClickEvent { 2 UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"舍弃流程?" delegate:self cancelButtonTitle:@"否" otherButtonTitles:@"是", nil]; 3 [alert show]; 4 CFRunLoopRun(); 5 6 return back; 7 } 8 9 - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { 10 //否 11 if (buttonIndex == 0) { 12 back = NO; 13 } 14 //是 15 else { 16 back = YES; 17 } 18 CFRunLoopStop(CFRunLoopGetMain()); 19 }
标签:style blog color for div sp 代码 log on
原文地址:http://www.cnblogs.com/Steak/p/3972734.html