Skip to content

Commit

Permalink
Fix crash on reloading the app (#7646)
Browse files Browse the repository at this point in the history
  • Loading branch information
yogevbd authored Nov 30, 2022
1 parent 632a881 commit 7b1c118
Showing 1 changed file with 0 additions and 51 deletions.
51 changes: 0 additions & 51 deletions lib/ios/RNNComponentView.m
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

0 comments on commit 7b1c118

Please sign in to comment.