本文共 1210 字,大约阅读时间需要 4 分钟。
在我的项目中有一个界面有两个tableView, 其它的像scrollView, collectionView都没有, 设置好了相应的scrollsToTop怎么都无效.
这是我的代码
_tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 45 * ScaleHeight, Width, Height - 64 - 45 * ScaleHeight) style:UITableViewStylePlain]; _tableView.delegate = self; _tableView.dataSource = self; _tableView.separatorStyle = UITableViewCellSeparatorStyleNone; _tableView.backgroundColor = [UIColor colorWithRed:0.94 green:0.95 blue:0.95 alpha:1.00]; _tableView.scrollsToTop = YES; [self.view addSubview:_tableView]; _tableView.tableFooterView = [[UITableView alloc] init]; // 注意这句话
_screenTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 20, _screenView.frame.size.width, Height - 20 - 40 * ScaleHeight) style:UITableViewStylePlain]; _screenTableView.delegate = self; _screenTableView.dataSource = self; _screenTableView.scrollsToTop = NO; _screenTableView.separatorStyle = UITableViewCellSeparatorStyleNone; [_screenView addSubview:_screenTableView];怎么设置也不好使, 就是我要放弃的时候我删除了"
_tableView.tableFooterView = [[UITableView alloc] init]; // 注意这句话"这段代码, 一开始为了去除底部的横线加了那句话, 后来用自定义cell那句话就没用了.
解决办法:
_tableView.tableFooterView = [[UITableView alloc] init];将这段代码删除.
转载地址:http://sntmb.baihongyu.com/