以编程方式向表格视图单元格添加按钮。

问题描述:

嘿伙计们我可以添加和删除单元格到我的表视图。我想为每个添加的单元格添加两个按钮。有人可以帮帮我吗?我找了这个,我找不到任何地方!我会喜欢一些帮助!非常感谢! :D

Hey guys i can add and delete cells to my table view. I want two buttons for each cell thats added. Could someone help me please? Ive looked for this and i cannot find it anywhere!! I would love some help! Thanks a lot! :D

添加按钮作为您的单元格的子视图。给它。我已经给出了样本

Add the button as subview for your cell.Tats it.I have given the sample

//Create ur cell then do the following    
UIButton *newBtn=[UIButton buttonWithType:UIButtonTypeCustom];
        [newBtn setFrame:CGRectMake(10,5,55,55)];
        [newBtn addTarget:self action:@selector(urSelctor:) forControlEvents:UIControlEventTouchUpInside];

        [cell addSubview:newBtn];