Browse Source

Add check if UIBarButtonItem is RNNUIBarButtonItem (#5850)

Alex Kolesnyk 5 years ago
parent
commit
233820ef37
1 changed files with 16 additions and 6 deletions
  1. 16
    6
      lib/ios/RNNNavigationButtons.m

+ 16
- 6
lib/ios/RNNNavigationButtons.m View File

73
 }
73
 }
74
 
74
 
75
 - (void)componentDidAppear {
75
 - (void)componentDidAppear {
76
-    for (RNNUIBarButtonItem* barButtonItem in [self currentButtons]) {
77
-        [barButtonItem notifyDidAppear];
76
+    for (UIBarButtonItem* barButtonItem in [self currentButtons]) {
77
+	  if ([self isRNNUIBarButton:barButtonItem]) {
78
+		  [(RNNUIBarButtonItem *)barButtonItem notifyDidAppear];
79
+	  }
78
     }
80
     }
79
 }
81
 }
80
 
82
 
81
 - (void)componentDidDisappear {
83
 - (void)componentDidDisappear {
82
-    for (RNNUIBarButtonItem* barButtonItem in [self currentButtons]) {
83
-        [barButtonItem notifyDidDisappear];
84
+    for (UIBarButtonItem* barButtonItem in [self currentButtons]) {
85
+	  if ([self isRNNUIBarButton:barButtonItem]) {
86
+		  [(RNNUIBarButtonItem *)barButtonItem notifyDidDisappear];
87
+	  }
84
     }
88
     }
85
 }
89
 }
86
 
90
 
87
 - (void)notifyButtonsDidAppear:(NSArray *)barButtonItems {
91
 - (void)notifyButtonsDidAppear:(NSArray *)barButtonItems {
88
-    for (RNNUIBarButtonItem* barButtonItem in barButtonItems) {
89
-        [barButtonItem notifyDidAppear];
92
+    for (UIBarButtonItem* barButtonItem in barButtonItems) {
93
+	  if ([self isRNNUIBarButton:barButtonItem]) {
94
+		  [(RNNUIBarButtonItem *)barButtonItem notifyDidAppear];
95
+	  }
90
     }
96
     }
91
 }
97
 }
92
 
98
 
99
+- (BOOL)isRNNUIBarButton:(UIBarButtonItem *)barButtonItem {
100
+    return [barButtonItem isKindOfClass:[RNNUIBarButtonItem class]];
101
+}
102
+
93
 - (void)clearPreviousButtonViews:(NSArray<UIBarButtonItem *> *)newButtons oldButtons:(NSArray<UIBarButtonItem *> *)oldButtons {
103
 - (void)clearPreviousButtonViews:(NSArray<UIBarButtonItem *> *)newButtons oldButtons:(NSArray<UIBarButtonItem *> *)oldButtons {
94
     NSArray<UIBarButtonItem *>* removedButtons = [oldButtons difference:newButtons withPropertyName:@"customView"];
104
     NSArray<UIBarButtonItem *>* removedButtons = [oldButtons difference:newButtons withPropertyName:@"customView"];
95
     
105