Rob*_* B. 18 objective-c uitableview uikit ios
我有一个简单的样式表,有多个部分.
症状:首次加载表时,每个单元格都有正常的分隔符,除了每个部分中的最后一个单元格(即"标题之前").但是,当滚动时,在某些单元格上会出现分隔符.此外,如果选择了单元格,然后取消选择,则会出现分隔符.
打印视图层次结构显示,在干净启动时,隐藏了每个部分中最后一个单元格的分隔符视图,因此我认为这将是正常行为:
<_UITableViewCellSeparatorView: 0x145b1990;
frame = (0 47.5; 320 0.5);
hidden = YES;
layer = <CALayer: 0x145b2950>>
Run Code Online (Sandbox Code Playgroud)
有时滚动; 并选择细胞; 此隐藏属性将被删除,因此显示分隔符.
第一个假设是我做错了事; 但这也发生在最基本的hello world应用程序中:
- (void)viewDidLoad {
[super viewDidLoad];
[self.tableView reloadData];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 4;
}
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section {
return 2;
}
- (NSString *)tableView:(UITableView *)tableView
titleForHeaderInSection:(NSInteger)section {
return @"test";
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *reuseIdentifier = @"TestCell";
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:reuseIdentifier];
return cell;
}
Run Code Online (Sandbox Code Playgroud)
屏幕(左:开始后;右:选择单元格后):

这是Apple的一个错误,还是我错过了什么?此外,例如,在iOS Contacts应用程序中,分隔符永远不会隐藏在节标题上方...
**更新:**
能够重现这个库存音乐应用程序:例如歌曲选项卡,没有语言.选择然后取消选择任何部分的第一个单元格; 分隔符出现.
额外信息:iOS 7.1
由于这是一个iOS 7.1错误,作为一种解决方法,我建议隐藏内置分隔符并在每个单元格的底部显示您自己的一个.
[self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *reuseIdentifier = @"TestCell";
XXYourCustomCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
cell.customSeparatorView.hidden = (indexPath.row == ([self numberOfRowsInSection:indexPath.section] - 1));
return cell;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8388 次 |
| 最近记录: |