10
votes

I have dragged out a splitViewController, and identified it as a subclass I have created MySplitViewController.

When Right-clicking the splitview storyboard I can see that I've set its Master and Detail view controllers, and furthermore that the delegate is NOT set.

I have made my subclass conform to the protocol and implemented some methods, but they are not being called (which I not understand is because the delegate is not set).

But whenever I try to ctrl+drag from the delegate option in the storyboard to my class, it won't link up. In fact, it won't link up with anything. Am I using this protocol wrong, should my subclass of UISplitViewController not be its own delegate? Then where do I define the delegate in code or otherwise?

Thank you for your time.

Edit: More info-

I tried putting self.delegate = self; in viewDidLoad, but that didn't seem to help.

The particular method I am trying to override is

splitViewControllerPreferredInterfaceOrientationForPresentation:

and I've put an NSLog in the code to notify me if it gets called, which it isn't

1
I'm having similar issues myself, setting the delegate. I've tried all sorts, making the detail view delegate, making the split view delegate, assigning the delegate in the app delegate, making an NSObject subclass that conforms to the delegate protocol and then adding an object in the storyboard scene of this custom type. Still no joy. Is this a lifecycle issue? A bug in Xcode? Did you fix your problem?user544565
I have managed to get the delegate hooked up so some of the methods work. However splitViewControllerPreferredInterfaceOrientationForPresentation: does not seem to be one of them. I wonder if these methods are not being called because something else in the view hierarchy is calling similar orientation methods?user544565

1 Answers

-1
votes

As far as I know, NSSplitViewControllers cannot have delegates, and their splitViews can't have their delegates reassigned since the controller acts as the delegate.

If you need access to the delegate methods, simply subclass the controller, then change the class name in Interface Builder.