简体   繁体   中英

How to set Split View Controller Delegate from Storyboard?

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

As far as I know, NSSplitViewController s cannot have delegates, and their splitView s 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM