【发布时间】:2016-02-13 11:27:14
【问题描述】:
【问题讨论】:
标签: ios swift uitableview
【问题讨论】:
标签: ios swift uitableview
喜欢在viewDidLoad 上将tableFooterView 框架设置为CGRectZero
override func viewDidLoad() {
super.viewDidLoad()
// set as your tableFooterView frame as CGRectZero it hides the empty rows
self.tableView.tableFooterView = UIView(frame: CGRectZero)
self.tableView.backgroundColor = UIColor.clearColor()
}
【讨论】:
//Obj-c code
TableName.tableFooterView = [[UIView alloc]initWithFrame:CGRectZero];
//Swift code
tableView.tableFooterView = UIView(frame: .zero)
使用此代码隐藏多余的行。
将此代码放入 ViewDidLoad 或 ViewWillApper
【讨论】:
在你的 viewDidLoad 方法中包含
self.localTableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
在 viewDidLayoutSubViews 中包含
-(void)viewDidLayoutSubviews
{
if ([self.localTableView respondsToSelector:@selector(setSeparatorInset:)]) {
[self.localTableView setSeparatorInset:UIEdgeInsetsZero];
}
if ([self.localTableView respondsToSelector:@selector(setLayoutMargins:)]) {
[self.localTableView setLayoutMargins:UIEdgeInsetsZero];
}
}
在tableView willDisplyCell 委托方法中包含
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
[cell setSeparatorInset:UIEdgeInsetsZero];
}
if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
[cell setLayoutMargins:UIEdgeInsetsZero];
}
}
这里 localTableView 是从情节提要中取出的插座
【讨论】:
// 斯威夫特 3
override func viewDidLoad() {
super.viewDidLoad()
tableView.tableFooterView = UIView(frame: .zero) }
【讨论】: