您的当前位置:首页正文

Swift设置section高度为0的方法

来源:东饰资讯网

只设置section高度而不做其它处理时,在OC下面找到

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section;
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section;

然后return 0.00001就可以了
但是,在swift中只是这样设置,是无效的,还要做如下处理

    public func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
        return UIView.init()
    }
    public func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
        return UIView.init()
    }

这样,就可将section的高度设置为0了。

不对的地方,还请各位多多指教。

显示全文