0

如何在 UITableView 的单元格外添加圆形矩形按钮?

例如 :

在此处输入图像描述

“Other”、“home”和“home”字段都是独立的单元格。

我想要实现的是添加按钮的能力,例如上面显示的“文本消息”、“共享联系人”和“添加到收藏夹”。

提前感谢您的建议!

4

3 回答 3

2

只需将页脚(或页眉)添加到适当的部分。

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    UIView *yourView = [[UIView alloc] initWithFrame:CGRectMake(x,x,x,x)];

    UIButton *yourButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    yourButton.frame = CGRectMake(x,x,x,x);
    [yourButton setTitle:@"Title" forState:UIControlStateNormal];

    [yourView addSubview:yourButton];

    return yourView;
}
于 2013-07-16T16:19:06.380 回答
1

基本上常规中有两种选择UITableViews.

  1. 它是一个内容视图和单元格本身具有透明背景的单元格。
  2. 它是一个节标题。注意会阻止你在那里发明一个新的部分,甚至是一个有 0 行的部分。然后您覆盖该tableView:viewForHeaderInSection:方法并提供一个适当的带有 buttond 和任何您喜欢的标题。这个也有一个透明的背景。
于 2013-07-16T15:10:42.037 回答
0

您需要一个具有透明背景的自定义单元格,并且可以在其上添加这些按钮。或者,您可以使用节页脚来做几乎相同的事情。

于 2013-07-16T15:04:51.520 回答