IBAction on a button in Custom UITableViewCell

后端 未结 2 1847
忘掉有多难
忘掉有多难 2021-02-04 21:17

Using iOS 5 : : : I have a scenario where I must create a tableView with Custom Cells. The custom cells have a Controller called TainingCellController Subclass of UITableViewCel

2条回答
  •  别跟我提以往
    2021-02-04 22:00

    Try working out with dynamic buttons on the same tableView class

    -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        if (cell == nil) 
        { 
            NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"WorkRequestedCC" owner:self options:nil];
    {
            for (id oneObject in nib) if ([oneObject isKindOfClass:[WorkRequestedCC class]])
                cell = (WorkRequestedCC *)oneObject;
    
    
        }
    
        UILabel *Button=[[UIBUtton alloc]initWithFrame:CGRectMake(792, 13, 10, 15)];
    
        [Button addTarget:self action:@selector(ButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
        [cell.contentView addSubview:Button];
    }
    
    -(void) ButtonClicked
    {
        //your code here
         }
    }
    

提交回复
热议问题