Fixed crash in RCTScrollView on iOS 8

Reviewed By: javache

Differential Revision: D4508906

fbshipit-source-id: 08955f338879f708d35f4784e858a92b542e8661
This commit is contained in:
Valentin Shergin
2017-02-03 15:13:36 -08:00
committed by Facebook Github Bot
parent f2ab27e321
commit 54d3e83bbf
3 changed files with 25 additions and 23 deletions

View File

@@ -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;
}

View File

@@ -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

View File

@@ -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