Skip to content

Commit dd5ccb6

Browse files
hongrichE-B-Smith
authored andcommitted
Update BNCStrongMatchHelper to handle UISplitViewController (#625)
Similar to how UINavigationController and UITabBarController is currently being handled when adding BNCMatchView. If we don't handle UISplitViewController this way, BNCMatchViewController will end up in the split view's viewControllers property which is unexpected and may lead to crashes later. Split view's viewControllers should only have 1 or 2 view controllers depending on its collapsed / expanded state. The special handling of UINavigationController and UITabBarController was added in #539
1 parent a678f1a commit dd5ccb6

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Branch-SDK/Branch-SDK/BNCStrongMatchHelper.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ - (UIWindow*) keyWindow {
254254
}
255255

256256
/**
257-
Find the top view controller that is not of type UINavigationController or UITabBarController
257+
Find the top view controller that is not of type UINavigationController, UITabBarController, UISplitViewController
258258
*/
259259
- (UIViewController *)topViewController:(UIViewController *)baseViewController {
260260
if ([baseViewController isKindOfClass:[UINavigationController class]]) {
@@ -265,6 +265,10 @@ - (UIViewController *)topViewController:(UIViewController *)baseViewController {
265265
return [self topViewController: ((UITabBarController *)baseViewController).selectedViewController];
266266
}
267267

268+
if ([baseViewController isKindOfClass:[UISplitViewController class]]) {
269+
return [self topViewController: ((UISplitViewController *)baseViewController).viewControllers.firstObject];
270+
}
271+
268272
if ([baseViewController presentedViewController] != nil) {
269273
return [self topViewController: [baseViewController presentedViewController]];
270274
}

0 commit comments

Comments
 (0)