I have an iPad interface defined in a storyboard, with a SplitViewController. I want to set the delegate of the SplitViewController to point to the detail controller, but IB won't allow that connection to be made.
Nothing works. I can set self.splitViewController.delegate = self
when detail view loads, and then it becomes the delegate with no problem. But I miss any delegate calls that happen before that point.
For context, I need to get the splitviewcontroller's delegate calls so that I can show a button in the detailview to show a popover, as is standard practice. Right now, if the app is launched in portrait, it has to be rotated to landscape and then back for the button to show.
I've done this with "normal" xibs with no issue. It seems to be a special case of the more general problem of not being allowed to connect outlets across scenes in a storyboard.
I have no idea why this worked this time and not the first 80 times, but I added this to my AppDelegate:
UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController;
UINavigationController *navigationController = [splitViewController.viewControllers lastObject];
splitViewController.delegate = (id)navigationController.topViewController;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With