-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix crash on reloading the app (#7646)
- Loading branch information
Showing
1 changed file
with
0 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,6 @@ | ||
#import "RNNComponentView.h" | ||
#import "RCTHelpers.h" | ||
|
||
@implementation RNNComponentView { | ||
BOOL _observeLayerChange; | ||
} | ||
|
||
- (void)layoutSubviews { | ||
[super layoutSubviews]; | ||
#ifdef DEBUG | ||
[self removeYellowBox]; | ||
#endif | ||
} | ||
|
||
#ifdef DEBUG | ||
- (void)removeYellowBox { | ||
if (self.subviews.count > 0 && self.subviews.firstObject.subviews.count > 0) { | ||
if (!_observeLayerChange) { | ||
[self.subviews.firstObject.subviews.firstObject.layer | ||
addObserver:self | ||
forKeyPath:@"sublayers" | ||
options:NSKeyValueObservingOptionNew | ||
context:nil]; | ||
_observeLayerChange = YES; | ||
} | ||
|
||
for (UIView *view in self.subviews.firstObject.subviews.firstObject.subviews) { | ||
if ([view.accessibilityLabel isEqualToString:@"! Yellow Box"]) { | ||
view.layer.opacity = 0; | ||
view.layer.zPosition = -100; | ||
} | ||
} | ||
} | ||
} | ||
|
||
- (void)observeValueForKeyPath:(NSString *)keyPath | ||
ofObject:(id)object | ||
change:(NSDictionary *)change | ||
context:(void *)context { | ||
if ([keyPath isEqualToString:@"sublayers"]) { | ||
if (((CALayer *)object).sublayers.count > 1) { | ||
((CALayer *)object).sublayers.lastObject.opacity = 0; | ||
((CALayer *)object).sublayers.lastObject.zPosition = -100; | ||
} | ||
} | ||
} | ||
|
||
- (void)dealloc { | ||
if (_observeLayerChange) { | ||
[self.subviews.firstObject.subviews.firstObject.layer removeObserver:self | ||
forKeyPath:@"sublayers"]; | ||
} | ||
} | ||
|
||
#endif | ||
|
||
@end |