mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-13 12:26:45 +08:00
Remove compatible system code for iOS8 and before (#23656)
Summary: We already only support `iOS9+`, so we can remove all compatible codes now. [iOS] [Fixed] - Remove compatible system code for iOS8 and before Pull Request resolved: https://github.com/facebook/react-native/pull/23656 Differential Revision: D14224986 Pulled By: hramos fbshipit-source-id: cac9ffe6788dd3eaf4f4f5f2b219f325ba78e85f
This commit is contained in:
committed by
Facebook Github Bot
parent
58c956768a
commit
06c6c7c673
@@ -222,37 +222,12 @@ static UIColor *defaultPlaceholderColor()
|
||||
- (CGSize)sizeThatFits:(CGSize)size
|
||||
{
|
||||
// Returned fitting size depends on text size and placeholder size.
|
||||
CGSize textSize = [self fixedSizeThatFits:size];
|
||||
CGSize textSize = [super sizeThatFits:size];
|
||||
CGSize placeholderSize = self.placeholderSize;
|
||||
// Returning size DOES contain `textContainerInset` (aka `padding`).
|
||||
return CGSizeMake(MAX(textSize.width, placeholderSize.width), MAX(textSize.height, placeholderSize.height));
|
||||
}
|
||||
|
||||
- (CGSize)fixedSizeThatFits:(CGSize)size
|
||||
{
|
||||
// UITextView on iOS 8 has a bug that automatically scrolls to the top
|
||||
// when calling `sizeThatFits:`. Use a copy so that self is not screwed up.
|
||||
static BOOL useCustomImplementation = NO;
|
||||
static dispatch_once_t onceToken;
|
||||
dispatch_once(&onceToken, ^{
|
||||
useCustomImplementation = ![[NSProcessInfo processInfo] isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){9,0,0}];
|
||||
});
|
||||
|
||||
if (!useCustomImplementation) {
|
||||
return [super sizeThatFits:size];
|
||||
}
|
||||
|
||||
if (!_detachedTextView) {
|
||||
_detachedTextView = [UITextView new];
|
||||
}
|
||||
|
||||
_detachedTextView.attributedText = self.attributedText;
|
||||
_detachedTextView.font = self.font;
|
||||
_detachedTextView.textContainerInset = self.textContainerInset;
|
||||
|
||||
return [_detachedTextView sizeThatFits:size];
|
||||
}
|
||||
|
||||
#pragma mark - Context Menu
|
||||
|
||||
- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
|
||||
|
||||
Reference in New Issue
Block a user