Commits

Anonymous committed 983f550

Setting controller's tabview will send appearance messages to the selected view controller only if the tabview exists and is in a window

Comments (0)

Files changed (1)

BWTabViewController.m

     }
     
     
-    // Keep selection in sync. It would be lying to the controller if tabview is nil, sinc it isn't really appearing. And sending -bind:… to nil has no effect, so is safe to skip
-    if (tabView)
-    {
-        [[self selectedViewController] viewWillAppear:NO];
-        
-        [tabView bind:NSSelectedIndexBinding
-             toObject:self
-          withKeyPath:@"selectedIndex"
-              options:nil];
-        
-        [[self selectedViewController] viewDidAppear:NO];
-    }
+    // Keep selection in sync. It would be lying to the controller if tabview is not onscreen, since it isn't really appearing. Sending -bind:… to nil has no effect, so is safe to skip
+    if ([tabView window]) [[self selectedViewController] viewWillAppear:NO];
+    
+    [tabView bind:NSSelectedIndexBinding
+         toObject:self
+      withKeyPath:@"selectedIndex"
+          options:nil];
+    
+    if ([tabView window]) [[self selectedViewController] viewDidAppear:NO];
 }
 
 - (BOOL)isTabViewLoaded { return (_tabView != nil); }