SebastienMichoy/MSSlidingPanelController

How to use delegate methods using storyboard

Closed this issue · 2 comments

Hi. I implemented the control using the Storyboard. In reference to the example in the source, to "Center view" I have assigned a controller in which I imported "MSSlidingPanelController.h" and I added the delegate "MSSlidingPanelControllerDelegate." In the implementation file I added the delegate method

  • (void) slidingPanelController: (MSSlidingPanelController *) panelController beginsToBringOutSide: (MSSPSideDisplayed) side
  • (void) slidingPanelController: (MSSlidingPanelController *) panelController hasClosedSide: (MSSPSideDisplayed) side
  • (void) slidingPanelController: (MSSlidingPanelController *) panelController hasOpenedSide: (MSSPSideDisplayed) side

but they do not run (XCode does not return any error). In other words, how should I proceed to execute the methods of the delegate using storyboard? Can you give me some guidance in this regard? Thanks for the excellent work and accomplishments!

Hi!

In the following example I show you how to assign a "center view" controller which will be the delegate.

CenterViewController.h:

#import <UIKit/UIKit.h>

@interface CenterViewController : UITableViewController

@end

CenterViewController.m:

#import "CenterViewController.h"
#import "MSSlidingPanelController.h"
#import "MSViewControllerSlidingPanel.h"

@interface CenterViewController () <MSSlidingPanelControllerDelegate>

@end

@implementation CenterViewController

- (void)viewDidLoad
{
    [super viewDidLoad];

    [[self slidingPanelController] setDelegate:self];
}

- (void)slidingPanelController:(MSSlidingPanelController *)panelController beginsToBringOutSide:(MSSPSideDisplayed)side
{
    NSLog(@"slidingPanelController:beginsToBringOutSide:");
}

- (void)slidingPanelController:(MSSlidingPanelController *)panelController hasClosedSide:(MSSPSideDisplayed)side
{
    NSLog(@"slidingPanelController:hasClosedSide:");
}

- (void)slidingPanelController:(MSSlidingPanelController *)panelController hasOpenedSide:(MSSPSideDisplayed)side
{
    NSLog(@"slidingPanelController:hasOpenedSide:");
}

@end

I guess you just forgot the content of viewDidLoad.
Let me know if I didn't understand your problem correctly.

Hi Sebastien, your solution works fine. Indeed I did not set the delegate in viewDidLoad. Thanks.

Costantino