简体   繁体   English

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

[英]Tableview custom cell did select items not working

I am trying to implement segue when the user taps the cell I have to move to a new view controller 当用户点击要移动到新视图控制器的单元格时,我正在尝试实现segue

The problem is that the method didselectrow is not being called 问题在于方法didselectrow没有被调用

I have set the delegate and datasource for the table view too 我也为表视图设置了委托和数据源

- (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];

}

Make sure you have a segue with identifier @"i1" 确保您的标识是@“ i1”

Console log to check if method is actually being called or not 控制台日志,以检查是否实际上正在调用方法

Remove the delegate and set it again programatically 删除委托并以编程方式再次设置它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM