【问题标题】:iOS UITableview hidden separator lineiOS UITableview 隐藏分隔线
【发布时间】:2013-07-01 12:04:47
【问题描述】:

在下图中,

我想隐藏分隔线从第五个开始,

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.mainTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStylePlain];

    [self.mainTableView setDelegate:self];
    [self.mainTableView setDataSource:self];
    [self.view addSubview:self.mainTableView];
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 4; //4 row
}

【问题讨论】:

    标签: iphone ios uitableview separator


    【解决方案1】:

    将此 tableview 委托方法添加到您的代码中

    - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section 
    {
        return 0.001f;
    }
    

    这将只显示有内容的行的分隔线

    【讨论】:

    • @HussainShabbir,对于 iOS 7,单独使用 self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero]; 很容易将分隔线仅显示到有内容的行。
    猜你喜欢
    • 1970-01-01
    • 2015-11-05
    • 2015-10-04
    • 2021-02-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多