我想從一個表視圖單元傳遞數據到下一個UIViewController。我使用的導航器也,但是當我點擊單元格,然後把它給錯誤: -- [UIViewController setSelectedRowTitle:]:無法識別的選擇發送到實例0x13fab360
-[UIViewController setSelectedRowTitle:]: unrecognized selector sent to instance 0x13fab360
我用它去下一個數據是我prepareForSegue代碼: -
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [NearBy_PlacesArray count];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *TableIdentifire = @"NearMe";
NearByTableViewCell *cell = (NearByTableViewCell*)[self.tableView dequeueReusableCellWithIdentifier:TableIdentifire];
if (cell == nil)
{
cell = [[NearByTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:TableIdentifire];
}
NearByPlace *nearBy = [NearBy_PlacesArray objectAtIndex:indexPath.row];
cell.NearBy_Thumbnail_Image.image = [UIImage imageNamed:nearBy.NearByImageName];
cell.NearBy_TitleLabel.text = nearBy.NearByPlaceName;
cell.NearBy_NoLabel.text = nearBy.NearByPlace_no;
return cell;
}
-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"ShowNearByPlaces"])
{
NSIndexPath *indexPath = nil;
NearByPlace *nearPlace = nil;
indexPath = [self.tableView indexPathForSelectedRow];
nearPlace = [NearBy_PlacesArray objectAtIndex:indexPath.row];
NSLog(@"indexPath-- %@ \n" , indexPath);
NSLog(@"recipe-- %@ \n " , nearPlace);
nearByPlaceDetail_ViewController *destViewController = segue.destinationViewController;
destViewController.SelectedRowTitle = nearPlace;
}
}