Kov*_*dra 37 iphone objective-c uitableview ipad ios
在iPad设备上运行时,我无法在iOS 7上更改静态UITableViewCells的背景颜色.您可以使用以下设置轻松检查:
现在,在iPhone和iPad模拟器(iOS 7)上运行该应用程序.
在iPhone模拟器上,一切都很好;
在iPad模拟器上,所有细胞都是白色的.
我尝试通过在Interface Builder中为单元格设置运行时属性来强制iPad正常工作:
backgroundColor 清除颜色contentView.backgroundColor 清除颜色backgroundView 没有但没有任何帮助.实际上,设置运行时属性contentView.backgroundColor将改变单元格颜色,但它不能用于清晰的颜色(这意味着在其后面有另一个白色的视图).
相同版本的iOS上的两个设备产生不同的结果是非常奇怪的.其他人可以确认这个bug吗?
有没有人有这个问题的解决方案,或唯一的方法是去动态属性+设置颜色cellForRowAtIndexPath?我想使用静态单元格,因为问题的本质是静态的.
ps我刚刚意识到我忘了尝试将backgroundView.backgroundColor运行时属性设置为清除颜色,而我目前无法访问Mac.也许这会成功.
fab*_*tus 57
做这个:
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
UIImage *pattern = [UIImage imageNamed:@"image.png"];
[cell setBackgroundColor:[UIColor colorWithPatternImage:pattern]];
}
Run Code Online (Sandbox Code Playgroud)
在IOS7上为我工作
小智 10
According to Apple's doc:
Whether you use a predefined or custom cell, you can change the cell’s background using the
backgroundViewproperty or by changing the inheritedbackgroundColorproperty. In iOS 7, cells have a white background by default; in earlier versions of iOS, cells inherit the background color of the enclosing table view. If you want to change the background color of a cell, do so in thetableView:willDisplayCell:forRowAtIndexPath:method of your table view delegate.
So no matter what color you set in tableView:cellForRowAtIndexPath:, iOS 7 changes it to white later. Just set it in tableView:willDisplayCell:forRowAtIndexPath:. Worked for me perfectly.
| 归档时间: |
|
| 查看次数: |
18327 次 |
| 最近记录: |