【发布时间】:2014-05-23 08:53:12
【问题描述】:
我正在尝试将数据从一个表格视图单元传递到下一个 UIViewController。我也在使用导航控制器,但是当我单击单元格时,它会给出错误:-
-[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;
}
}
【问题讨论】:
标签: uitableview cell segue custom-cell