PS:我可以发布一个小视频,但似乎没必要.
使用Xcode 6.4(当前使用6E35b)创建示例项目.创建一个简单的UITableViewController子类,并使用故事板或以编程方式呈现它.
尝试应用切换.当应用程序进入后台或前台时,看起来tableview分隔符会闪烁.滚动时不会闪烁等.
要更好地了解它,请使用:
self.tableView.backgroundColor = [UIColor whiteColor];
self.tableView.rowHeight = 75.0f
self.tableView.separatorColor = self.view.tintColor;
Run Code Online (Sandbox Code Playgroud)
我不确定为什么会这样.我已经提到了iPhone 6/6 Plus:UITableView分离器闪烁和不同的厚度,但默认项目总是有一个启动屏幕IB文件.
您可以在iOS上的默认设置应用中查看该问题.在大多数情况下,除非您正在渲染图像并且突然白色分隔线flickr,否则这不会成为问题.
编辑1:对我来说最大的问题是,即使我使用:
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
Run Code Online (Sandbox Code Playgroud)
分隔符暂时渲染然后消失; 与其他情况完全相同.有关详细信息,请参阅编辑2.
编辑2(2015年4月7日,下午8时16分):我想在此提供更多示例.我观察到的闪烁行为在自定义表格视图单元格中更为突出(即,您可以自由地使用自定义属性设置渲染自己的图像视图等).
另一个观察结果是特定的闪烁行为(即在其中的情况下separatorStyle == UITableViewCellSeparatorStyleNone)对于仅文本的单元格是不明显的.在图表视图单元格中呈现图像的情况下,它主要是显而易见的.
以下是表格视图单元格的示例:
@interface BTableViewCell ()
@property (nonatomic, strong, readwrite) UIImageView *mainImageView;
@end
@implementation BTableViewCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self)
{
[self commonInit];
}
return self;
}
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if (self)
{
[self commonInit];
}
return self;
}
- (void)commonInit
{
// Initialize Avatar Image
self.mainImageView = [[UIImageView alloc] init];
_mainImageView.translatesAutoresizingMaskIntoConstraints = NO;
_mainImageView.layer.masksToBounds = YES;
[self.contentView addSubview:_mainImageView];
[self configureConstraintsForImageView];
}
- (void)configureConstraintsForImageView
{
[self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:_mainImageView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeHeight multiplier:1 constant:0]];
[self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:_mainImageView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeWidth multiplier:1 constant:0]];
}
@end
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
BTableViewCell*cell = [tableView dequeueReusableCellWithIdentifier:@"CellIdentifier"];
NSString *imagePath = [[NSBundle mainBundle] pathForResource:@"image" ofType:@"jpeg"];
UIImage* image = [UIImage imageWithContentsOfFile:imagePath];
cell.mainImageView.image = image; //ignore unoptimized load
return cell;
}
Run Code Online (Sandbox Code Playgroud)如果masksToBounds属性,闪烁几乎消失false.我不确定为什么会出现这种情况,或者这是否是预期的方式.
而不是使用自定义表视图单元格,请使用默认UITableViewCell类.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell*cell = [tableView dequeueReusableCellWithIdentifier:@"CellIdentifier"];
NSString *imagePath = [[NSBundle mainBundle] pathForResource:@"image" ofType:@"jpeg"];
UIImage* image = [UIImage imageWithContentsOfFile:imagePath];
cell.backgroundView = [[UIImageView alloc] initWithImage:image];
return cell;
}
Run Code Online (Sandbox Code Playgroud)值得注意的是#2和#3的闪烁行为或多或少相同.与#1中的相比,它更加微妙,但仍然很明显.
我有一段时间遇到同样的问题。我对如何处理这个问题做了很长时间的研究,但从未找到有用的东西。我得出的结论是,没有人注意到,而且无论谁注意到,都不关心appswitch table view 的 0.6f 线。但如果你仍然需要这个,我找到了一些解决方法。除了使用UITableViewCellSeparatorStyleNonealso do[self.tableView setSeparatorColor:[UIColor myColor]]和你能做的最后一件事之外,如果你可以像facebook ios应用程序那样在单元格之间有间隙,那么将背景颜色设置为某种灰色。
| 归档时间: |
|
| 查看次数: |
1443 次 |
| 最近记录: |