我得到這個錯誤,當我玩了我剛剛實施的搜索欄..一些字母的工作,而其他人會崩潰的錯誤標題。錯誤似乎是在這裏,但我無法弄清楚什麼是錯的:終止應用程序由於未捕獲的異常'NSInvalidArgumentException'原因 - >無法識別的選擇器發送到實例
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[BIDPresidentDetailViewController rowImage]: unrecognized selector sent to instance 0x754e360'
*第一擲調用堆棧:
我有下面的代碼中,是給我的.m文件我上面的錯誤。我不知道是什麼,我在我的代碼所做的錯誤:
#pragma mark - Table view data source
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return kNumberOfEditableRows;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
// Configure the cell...
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 75, 25)];
label.tag = kLabelTag;
label.textAlignment = NSTextAlignmentRight;
label.font = [UIFont boldSystemFontOfSize:14];
[cell.contentView addSubview:label];
UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(90, 12, 200, 25)];
textField.tag = kTextFieldTag;
textField.clearsOnBeginEditing = NO;
textField.delegate = self;
textField.returnKeyType = UIReturnKeyDone;
[textField addTarget:self action:@selector(textFieldDone:) forControlEvents:UIControlEventEditingDidEndOnExit];
[cell.contentView addSubview:textField];
}
UILabel *label = (id)[cell viewWithTag:kLabelTag];
label.text = self.fieldLabels[indexPath.row];
UITextField *textField = (id)[cell viewWithTag:kTextFieldTag];
textField.superview.tag = indexPath.row;
switch (indexPath.row) {
case kNameRowIndex:
textField.text = self.president.name;
break;
case kFromYearRowIndex:
textField.text = self.president.fromYear;
break;
case kToYearRowIndex:
textField.text = self.president.toYear;
break;
case kPartyIndex:
textField.text = self.president.party;
break;
default:
break;
}
return cell;
}
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
initialText = textField.text;
}
- (void)textFieldDidEndEditing:(UITextField *)textField
{
if (![textField.text isEqualToString:initialText]) {
hasChanges = YES;
switch (textField.superview.tag) {
case kNameRowIndex:
self.president.name = textField.text;
break;
case kFromYearRowIndex:
self.president.fromYear = textField.text;
break;
case kToYearRowIndex:
self.president.toYear = textField.text;
break;
case kPartyIndex:
self.president.party = textField.text;
break;
default:
break;
}
}
}
@end
請幫我在這裏爲我吃的大腦和從昨天起我堅持就可以了!
好的,那麼錯誤消息「無法識別的選擇器發送給實例」是什麼意思?這是一個非常重要的問題,你會在這個網站上找到很多例子和解決方案。他們不會100%滿足你的問題,但他們應該給你自己解決這個問題的重要線索。 – trojanfoe
上面的代碼在嘗試運行應用程序時給了我錯誤。我對objective-c是新手,不知道我做了什麼錯誤。任何幫助將不勝感激。 –
這不能回答我的問題。那句話對你意味着什麼?如果你(氣喘吁吁)搜索它,你認爲你會找到任何參考嗎? – trojanfoe