[ios] Fixed incorrect cells size in iPAD.

This commit is contained in:
VladiMihaylenko 2016-10-31 11:59:09 +03:00 committed by Илья Гречухин
parent 7ca91ce5f6
commit fc9e0b5f91
3 changed files with 9 additions and 26 deletions

View file

@ -690,20 +690,15 @@ using namespace storage;
{
case MWMPlacePageCellTypeBookmark: return ((MWMPlacePageBookmarkCell *)cell).cellHeight;
case MWMPlacePageCellTypeOpenHours: return ((MWMPlacePageOpeningHoursCell *)cell).cellHeight;
default:
{
[cell setNeedsUpdateConstraints];
[cell updateConstraintsIfNeeded];
cell.bounds = {{}, {CGRectGetWidth(tableView.bounds), CGRectGetHeight(cell.bounds)}};
[cell setNeedsLayout];
[cell layoutIfNeeded];
CGSize const size =
[cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];
return size.height;
}
default: return UITableViewAutomaticDimension;
}
}
- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return UITableViewAutomaticDimension;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [self cellsForSection:section].size();

View file

@ -14,7 +14,6 @@
@property(weak, nonatomic, readwrite) IBOutlet UIImageView * icon;
@property(weak, nonatomic, readwrite) IBOutlet id textContainer;
@property(weak, nonatomic) IBOutlet NSLayoutConstraint * textContainerHeight;
@property(weak, nonatomic) IBOutlet UIButton * upperButton;
@property(weak, nonatomic) IBOutlet UIImageView * toggleImage;
@ -33,10 +32,11 @@
if ([self.textContainer isKindOfClass:[UITextView class]])
{
UITextView * textView = (UITextView *)self.textContainer;
textView.textContainerInset = {.left = -5, .top = 12};
textView.textContainerInset = {.left = -5, .top = 12, .bottom = 12};
textView.keyboardAppearance =
[UIColor isNightMode] ? UIKeyboardAppearanceDark : UIKeyboardAppearanceDefault;
}
[self.icon layoutIfNeeded];
}
- (void)configWithRow:(place_page::MetainfoRows)row data:(MWMPlacePageData *)data;
@ -143,19 +143,11 @@
[tv setAttributedText:[[NSAttributedString alloc]
initWithString:text
attributes:@{NSFontAttributeName : [UIFont regular16]}]];
[tv sizeToIntegralFit];
CGFloat const minTextContainerHeight = 42.0;
CGFloat const bottomOffset = 8.0;
self.textContainerHeight.constant =
MAX(ceil(tv.contentSize.height) + bottomOffset, minTextContainerHeight);
}
else
{
UILabel * lb = (UILabel *)self.textContainer;
[lb setText:text];
[lb sizeToIntegralFit];
CGFloat const trailingOffset = self.width - lb.maxX;
lb.font = trailingOffset < 32 ? [UIFont regular15] : [UIFont regular16];
}
}

View file

@ -12,7 +12,7 @@
<rect key="frame" x="0.0" y="0.0" width="320" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="DKh-ne-anv" id="M4j-cz-kSo">
<frame key="frameInset" width="320" height="43"/>
<frame key="frameInset" width="320" height="43.5"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="DT5-2i-vCG">
@ -26,9 +26,6 @@
</imageView>
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" scrollEnabled="NO" showsHorizontalScrollIndicator="NO" showsVerticalScrollIndicator="NO" editable="NO" translatesAutoresizingMaskIntoConstraints="NO" id="T5l-Sb-Hfo">
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="height" relation="greaterThanOrEqual" priority="750" constant="42" id="2uD-kp-7lD"/>
</constraints>
<string key="text">Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda.</string>
<fontDescription key="fontDescription" type="system" weight="light" pointSize="16"/>
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
@ -63,7 +60,6 @@
<connections>
<outlet property="icon" destination="DT5-2i-vCG" id="Qu6-7I-lP5"/>
<outlet property="textContainer" destination="T5l-Sb-Hfo" id="K2l-dM-fky"/>
<outlet property="textContainerHeight" destination="2uD-kp-7lD" id="UxV-q5-Rbh"/>
</connections>
<point key="canvasLocation" x="120" y="202"/>
</tableViewCell>