此代碼顯示異常顯示異常:在單擊一行
'NSInvalidArgumentException', reason: '-[SelectHospitalViewController returncityname:]: unrecognized selector sent to instance
.h file
-(void)returncityname:(NSString*)CityList;
//.m file
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell==nil)
{
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
if (tableView==self.searchDisplayController.searchResultsTableView)
{
cell.textLabel.text = [self.SearchCityResult objectAtIndex:indexPath.row];
}
else
{
cell.textLabel.text = self.CityList[indexPath.row];
}
cell.textLabel.text = [_CityList objectAtIndex:indexPath.row];
return cell;
}
-(void)back
{
[self.navigationController popViewControllerAnimated:YES];
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)IndexPath
{
if (tableView==self.searchDisplayController.searchResultsTableView)
{
[self.delegate returncityname:[self.SearchCityResult objectAtIndex:IndexPath.row]];
}
else
{
[self.delegate returncityname:[_CityList objectAtIndex:IndexPath.row]];
}
[self dismissViewControllerAnimated:YES completion:nil];
}
在這段代碼中導致錯誤,我不能找出問題。 任何人都可以幫助我?
主張給rowClick提供代碼和returncityname方法 –
放例外休息的實例變量點,讓我知道,也讓我知道self.SearchCityResult和_cityList是包含字符串只有 – Spynet
其他 { [self.delegate returncityname: [_CityList objectAtIndex:IndexPath.row]]; } 它在這一點上顯示異常.. –