@@ -32,11 +32,18 @@ - (CGFloat)fd_systemFittingHeightForConfiguratedCell:(UITableViewCell *)cell {
3232 cellBounds.size .width = contentViewWidth;
3333 cell.bounds = cellBounds;
3434
35- CGFloat accessroyWidth = 0 ;
35+ CGFloat rightSystemViewsWidth = 0.0 ;
36+ for (UIView *view in self.subviews ) {
37+ if ([view isKindOfClass: NSClassFromString (@" UITableViewIndex" )]) {
38+ rightSystemViewsWidth = CGRectGetWidth (view.frame );
39+ break ;
40+ }
41+ }
42+
3643 // If a cell has accessory view or system accessory type, its content view's width is smaller
3744 // than cell's by some fixed values.
3845 if (cell.accessoryView ) {
39- accessroyWidth = 16 + CGRectGetWidth (cell.accessoryView .frame );
46+ rightSystemViewsWidth + = 16 + CGRectGetWidth (cell.accessoryView .frame );
4047 } else {
4148 static const CGFloat systemAccessoryWidths[] = {
4249 [UITableViewCellAccessoryNone] = 0 ,
@@ -45,9 +52,14 @@ - (CGFloat)fd_systemFittingHeightForConfiguratedCell:(UITableViewCell *)cell {
4552 [UITableViewCellAccessoryCheckmark] = 40 ,
4653 [UITableViewCellAccessoryDetailButton] = 48
4754 };
48- accessroyWidth = systemAccessoryWidths[cell.accessoryType];
55+ rightSystemViewsWidth + = systemAccessoryWidths[cell.accessoryType];
4956 }
50- contentViewWidth -= accessroyWidth;
57+
58+ if ([UIScreen mainScreen ].scale >= 3 && [UIScreen mainScreen ].bounds .size .width >= 414 ) {
59+ rightSystemViewsWidth += 4 ;
60+ }
61+
62+ contentViewWidth -= rightSystemViewsWidth;
5163
5264
5365 // If not using auto layout, you have to override "-sizeThatFits:" to provide a fitting size by yourself.
@@ -79,7 +91,7 @@ - (CGFloat)fd_systemFittingHeightForConfiguratedCell:(UITableViewCell *)cell {
7991
8092 // Build edge constraints
8193 NSLayoutConstraint *leftConstraint = [NSLayoutConstraint constraintWithItem: cell.contentView attribute: NSLayoutAttributeLeft relatedBy: NSLayoutRelationEqual toItem: cell attribute: NSLayoutAttributeLeft multiplier: 1.0 constant: 0 ];
82- NSLayoutConstraint *rightConstraint = [NSLayoutConstraint constraintWithItem: cell.contentView attribute: NSLayoutAttributeRight relatedBy: NSLayoutRelationEqual toItem: cell attribute: NSLayoutAttributeRight multiplier: 1.0 constant: accessroyWidth ];
94+ NSLayoutConstraint *rightConstraint = [NSLayoutConstraint constraintWithItem: cell.contentView attribute: NSLayoutAttributeRight relatedBy: NSLayoutRelationEqual toItem: cell attribute: NSLayoutAttributeRight multiplier: 1.0 constant: -rightSystemViewsWidth ];
8395 NSLayoutConstraint *topConstraint = [NSLayoutConstraint constraintWithItem: cell.contentView attribute: NSLayoutAttributeTop relatedBy: NSLayoutRelationEqual toItem: cell attribute: NSLayoutAttributeTop multiplier: 1.0 constant: 0 ];
8496 NSLayoutConstraint *bottomConstraint = [NSLayoutConstraint constraintWithItem: cell.contentView attribute: NSLayoutAttributeBottom relatedBy: NSLayoutRelationEqual toItem: cell attribute: NSLayoutAttributeBottom multiplier: 1.0 constant: 0 ];
8597 edgeConstraints = @[leftConstraint, rightConstraint, topConstraint, bottomConstraint];
0 commit comments