向tableviewcontroller添加多个图标页脚(一节)

时间:2010-12-01 04:29:18

标签: iphone uitableview

嗨我想在一个uitableviewcontroller的页脚中添加一个多个图标脚,它只包含整个单个部分。

我们如何添加这个?

2 个答案:

答案 0 :(得分:1)

实施- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section

让它返回一个视图,您在其中添加了图标。

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0,0, tableView.frame.size.width,tableView.frame.height)]; 

    UIImage *img = [UIImage imageNamed:@"nameofimage.png"];
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setBackgroundImage:img forState:UIControlStateNormal];
    [button addTarget:self 
               action:@selector(someSelector:) 
     forControlEvents:UIControlEventTouchUpInside]
    [view addSubView: button];
    return [view autorelease]
}

答案 1 :(得分:0)

要在tableview中添加页脚,您需要实现

-(UIView *) tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section.
在你的UITableViewDelegate中

。在该方法中,您可以创建并返回自定义页脚视图