【问题标题】:-[UIViewController setSelectedRowTitle:]: unrecognized selector sent to instance 0x13fab360-[UIViewController setSelectedRowTitle:]:无法识别的选择器发送到实例 0x13fab360
【发布时间】: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


    【解决方案1】:

    Mantosh,你可以这样做:

    • (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

      { 静态 NSString *aStrIdentifier = @"cell"; UITableViewCell *aCell=[tableView dequeueReusableCellWithIdentifier:aStrIdentifier];

      UILabel *aLblPlaceName=(UILabel*)[aCell viewWithTag:1];
      aLblPlaceName.text=[NSString stringWithFormat:@"%@", [arrPlaces objectAtIndex:indexPath.row]];
      
      return aCell;
      

      }

    • (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

      { strStoreValue = [NSString stringWithFormat:@"%@", [arrPlaces objectAtIndex:indexPath.row]]; [self performSegueWithIdentifier:@"detailViewSegue" sender:self]; }

    • (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender

      { DetailViewController *aObjDetailVC = segue.destinationViewController; aObjDetailVC.strPlace = strStoreValue; }

    【讨论】:

      猜你喜欢
      • 2014-01-13
      • 2012-08-01
      • 2013-06-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-07
      • 1970-01-01
      • 2019-08-28
      相关资源
      最近更新 更多