0
我使用下面的代碼來檢查文本字段是否爲空或不循環。 下面是我的代碼,它給出了以下錯誤。通過循環找到空文本字段
-[UIImageView text]: unrecognized selector sent to instance 0x997c930
2014年3月19日16:54:49.227 IS [2837:A0B] *終止應用程序由於未捕獲的異常 'NSInvalidArgumentException',原因:「 - [文本的UIImageView]:無法識別的選擇發送到實例0x997c930'
//code
NSString *strText;
NSMutableArray *arrMsgs = [[NSMutableArray alloc] init];
[arrMsgs addObject:@"*Manifest Type is reuired."];
[arrMsgs addObject:@"*Suffix Code is required."];
[arrMsgs addObject:@"*Aircraft Registry is required."];
[arrMsgs addObject:@"*Flight Number is required."];
[arrMsgs addObject:@"*Embarkation ICAO/IATA required."];
[arrMsgs addObject:@"*ETD date (Local) is required."];
[arrMsgs addObject:@"*ETD Time (Local) is required."];
[arrMsgs addObject:@"*ETA date (Local) is required."];
[arrMsgs addObject:@"*ETA Time (Local) is required."];
NSLog(@"array:%d", [arrMsgs count]);
for(int i=1; i<=9;i++)
{
UITextField *tf= (UITextField *)[self.view viewWithTag:i];
int k=0;
UILabel *lbl = (UILabel *)[self.view viewWithTag:k];
if([tf.text length] == 0)
{
strText = [arrMsgs objectAtIndex:i-1];
lbl.text = strText;
NSLog(@"strText1:%@", strText);
k++;
}
}
我沒有得到我錯在哪裏,請指導以上。它在上述錯誤的條件下崩潰。
我認爲你已經爲你的imageview設置了相同的標籤,你已經應用到你的textfields.Just給所有對象提供唯一標籤 – NiravPatel
@NiravPatel是的你是對的。 –