UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"......" message:@"......" delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:@"OK", nil];
[alert show];
我正在显示警报视图以使用警报视图的文本字段添加新类别,当用户点击警报的确定按钮时,我首先检查用户是否输入了任何内容,如果没有,则显示另一个警报,其中包含一些消息让用户知道文本字段是强制性的,但之前添加新类别的警报消失了。
我希望该警报留在屏幕上。所以我该怎么做 ??
这是崩溃报告和代码::
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Add Vehicle Category" message:@"this gets covered!" delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:@"OK", nil];
alert.tag = 5;
txtAddVehicleCategory = [[UITextField alloc]initWithFrame:CGRectMake(12, 45, 260, 25)];
[txtAddVehicleCategory setBackgroundColor:[UIColor whiteColor]];
txtAddVehicleCategory.placeholder = @"Enter Vehicle Category";
txtAddVehicleCategory.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
[alert addSubview:txtAddVehicleCategory];
CGAffineTransform myTransform = CGAffineTransformMakeTranslation(0, -50);
[alert setTransform:myTransform];
[alert show];
'NSInvalidArgumentException',原因:'textFieldIndex (0) 超出了文本字段数组的范围'