在iOS 8上,对于较大的设备,默认的tableView inset似乎发生了变化.如果您正在布置自定义单元格并将其左侧布局约束与单元格的默认大小15插入匹配,则您的布局在较小的设备上看起来会很好,但在插入更改的较大设备上,您将获得类似于以下内容的内容:

我怎样才能解决这个问题?
设法写了一些看起来效果很好的东西。如果有更好的解决方案,请分享。
@interface InsetRespectingTableViewCell()
@property (nonatomic) IBOutlet NSLayoutConstraint * leftContentInset;
@property (nonatomic) IBOutlet NSLayoutConstraint * rightContentInset;
@end
@implementation InsetRespectingTableViewCell
- (UITableView *)tableView {
UIView *view;
for (view = self.superview; ![view isKindOfClass:UITableView.class] && view; view = view.superview);
return (UITableView *)view;
}
- (void)updateInset {
CGFloat defaultInset = [self tableView].separatorInset.left;
self.leftContentInset.constant = defaultInset;
self.rightContentInset.constant = defaultInset;
}
- (void)didMoveToSuperview {
[super didMoveToSuperview];
[self updateInset];
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3892 次 |
| 最近记录: |