mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-06-17 06:29:17 +08:00
Fixed crash in RCTScrollView on iOS 8
Reviewed By: javache Differential Revision: D4508906 fbshipit-source-id: 08955f338879f708d35f4784e858a92b542e8661
This commit is contained in:
committed by
Facebook Github Bot
parent
f2ab27e321
commit
54d3e83bbf
@@ -160,10 +160,12 @@ RCT_NOT_IMPLEMENTED(- (instancetype)init)
|
||||
if ((self = [super initWithFrame:frame])) {
|
||||
[self.panGestureRecognizer addTarget:self action:@selector(handleCustomPan:)];
|
||||
|
||||
// We intentionaly force `UIScrollView`s `semanticContentAttribute` to `LTR` here
|
||||
// because this attribute affects a position of vertical scrollbar; we don't want this
|
||||
// scrollbar flip because we also flip it with whole `UIScrollView` flip.
|
||||
self.semanticContentAttribute = UISemanticContentAttributeForceLeftToRight;
|
||||
if ([self respondsToSelector:@selector(setSemanticContentAttribute:)]) {
|
||||
// We intentionaly force `UIScrollView`s `semanticContentAttribute` to `LTR` here
|
||||
// because this attribute affects a position of vertical scrollbar; we don't want this
|
||||
// scrollbar flip because we also flip it with whole `UIScrollView` flip.
|
||||
self.semanticContentAttribute = UISemanticContentAttributeForceLeftToRight;
|
||||
}
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -128,12 +128,12 @@ RCT_NOT_IMPLEMENTED(- (instancetype)initWithCoder:unused)
|
||||
{
|
||||
_reactLayoutDirection = layoutDirection;
|
||||
|
||||
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_9_0
|
||||
self.semanticContentAttribute =
|
||||
layoutDirection == UIUserInterfaceLayoutDirectionLeftToRight ?
|
||||
UISemanticContentAttributeForceLeftToRight :
|
||||
UISemanticContentAttributeForceRightToLeft;
|
||||
#endif
|
||||
if ([self respondsToSelector:@selector(setSemanticContentAttribute:)]) {
|
||||
self.semanticContentAttribute =
|
||||
layoutDirection == UIUserInterfaceLayoutDirectionLeftToRight ?
|
||||
UISemanticContentAttributeForceLeftToRight :
|
||||
UISemanticContentAttributeForceRightToLeft;
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *)accessibilityLabel
|
||||
|
||||
@@ -89,23 +89,23 @@
|
||||
|
||||
- (UIUserInterfaceLayoutDirection)reactLayoutDirection
|
||||
{
|
||||
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_9_0
|
||||
return [UIView userInterfaceLayoutDirectionForSemanticContentAttribute:self.semanticContentAttribute];
|
||||
#else
|
||||
return [objc_getAssociatedObject(self, @selector(reactLayoutDirection)) integerValue];
|
||||
#endif
|
||||
if ([self respondsToSelector:@selector(semanticContentAttribute)]) {
|
||||
return [UIView userInterfaceLayoutDirectionForSemanticContentAttribute:self.semanticContentAttribute];
|
||||
} else {
|
||||
return [objc_getAssociatedObject(self, @selector(reactLayoutDirection)) integerValue];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setReactLayoutDirection:(UIUserInterfaceLayoutDirection)layoutDirection
|
||||
{
|
||||
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_9_0
|
||||
self.semanticContentAttribute =
|
||||
layoutDirection == UIUserInterfaceLayoutDirectionLeftToRight ?
|
||||
UISemanticContentAttributeForceLeftToRight :
|
||||
UISemanticContentAttributeForceRightToLeft;
|
||||
#else
|
||||
objc_setAssociatedObject(self, @selector(reactLayoutDirection), @(layoutDirection), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
#endif
|
||||
if ([self respondsToSelector:@selector(setSemanticContentAttribute:)]) {
|
||||
self.semanticContentAttribute =
|
||||
layoutDirection == UIUserInterfaceLayoutDirectionLeftToRight ?
|
||||
UISemanticContentAttributeForceLeftToRight :
|
||||
UISemanticContentAttributeForceRightToLeft;
|
||||
} else {
|
||||
objc_setAssociatedObject(self, @selector(reactLayoutDirection), @(layoutDirection), OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
}
|
||||
}
|
||||
|
||||
- (NSInteger)reactZIndex
|
||||
|
||||
Reference in New Issue
Block a user