以编程方式向表格视图单元格添加按钮[关闭]

问题描述 投票:0回答:1

我可以在表视图中添加和删除单元格。如何为每个添加的单元格设置两个按钮?

ios uitableview uibutton
1个回答
7
投票

将按钮添加为单元格的子视图。而已。我给了样品:

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

[cell addSubview:newBtn];
© www.soinside.com 2019 - 2024. All rights reserved.