Explorar el Código

Add check if UIBarButtonItem is RNNUIBarButtonItem (#5850)

Alex Kolesnyk hace 5 años
padre
commit
233820ef37
Se han modificado 1 ficheros con 16 adiciones y 6 borrados
  1. 16
    6
      lib/ios/RNNNavigationButtons.m

+ 16
- 6
lib/ios/RNNNavigationButtons.m Ver fichero

@@ -73,23 +73,33 @@
73 73
 }
74 74
 
75 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 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 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 103
 - (void)clearPreviousButtonViews:(NSArray<UIBarButtonItem *> *)newButtons oldButtons:(NSArray<UIBarButtonItem *> *)oldButtons {
94 104
     NSArray<UIBarButtonItem *>* removedButtons = [oldButtons difference:newButtons withPropertyName:@"customView"];
95 105