Tableview自定义单元格确实选择了不起作用的项目

时间:2017-07-26 06:10:49

标签: ios objective-c uitableview

当用户点击我必须移动到新视图控制器的单元格时,我正在尝试实现segue

问题是该方法没有被称为

我也为表格视图设置了委托和数据源

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    NSLog(@" table vie cell----%lu",(unsigned long)_orderid.count);

    return _orderid.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    int section = [indexPath section];
    int row = [indexPath row];

    NSString* CellIdentifier = @"cell";

    TableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    cell.userInteractionEnabled = YES;

    if(_orderid != NULL) {

        // set tag to the indexPath.row so we can access it later
        [cell setTag:indexPath.row];    
        NSLog(@"%@ order id tv",_orderid);
        NSLog(@" order id tv %@",_orderid[indexPath.row]);

        cell.orderidlbl.text=_orderid[indexPath.row];
        //cell.orderidlbl.text =_orderid[indexPath.row];

        cell.datelbl.text    =_date[indexPath.row];

        cell.pricelbl.text   =[NSString stringWithFormat:@" ₹ %@",_totprice[indexPath.row]];
        //cell.viewbutton.tag  =indexPath.row;

    }

    //cell.nametxtv.text=[_nametb  objectAtIndex:indexPath.row];
    //cell.buynowprice.text=[_buytb objectAtIndex:indexPath.row];
    //cell.regularprice.text=[_regtb objectAtIndex:indexPath.row];
    //cell.lowestoff.text=[_lowesttb objectAtIndex:indexPath.row];

    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    [self performSegueWithIdentifier:@"i1" sender:self];

}

1 个答案:

答案 0 :(得分:0)

确保你有一个带有标识符@" i1"

的segue

控制台日志以检查方法是否实际被调用

删除委托并以编程方式再次设置