Steaphann
Steaphann

Reputation: 2777

Cannot perform a segue from my class

I am working with the library KYCircleMenu. You can find it over here. I am also working with storyboards. I made a Class MenuViewController that is derived from KYCircleMenu

@interface MenuViewController : KYCircleMenu

Next I have implemented my initWithCoder like this.

- (id)initWithCoder:(NSCoder*)aDecoder
{
    NSLog(@"called");
    if(self = [self initWithButtonCount:kKYCCircleMenuButtonsCount
                              menuSize:kKYCircleMenuSize
                            buttonSize:kKYCircleMenuButtonSize
                 buttonImageNameFormat:kKYICircleMenuButtonImageNameFormat
                      centerButtonSize:kKYCircleMenuCenterButtonSize
                 centerButtonImageName:kKYICircleMenuCenterButton
       centerButtonBackgroundImageName:kKYICircleMenuCenterButtonBackground]) 
    { 
        
        
    } 
    return self;
}

And finally I have implemented a method from the KyCicrleMenu RunButtonActions. This method tells me what button is pressed in the menu. So in this method I am trying to do a segue to another viewcontroller. I am doing it like this.

 NSLog(@"tag is %d",[sender tag]);
    [self performSegueWithIdentifier:@"showNews" sender:self];

(The log gives me the button tag from the button that is pressed). For some reason or another I keep getting this error.

Receiver (<MenuViewController: 0x1cd7cf50>) has no segue with identifier 'showNews''

Here is a screenshot from my storyboard.

enter image description here

Can anybody help me with this annoying problem?

Kind regards

Upvotes: 0

Views: 127

Answers (1)

jrturton
jrturton

Reputation: 119242

- (id)initWithCoder:(NSCoder*)aDecoder
{
    NSLog(@"called");
    if(self = [self initWithButtonCount:kKYCCircleMenuButtonsCount
                              menuSize:kKYCircleMenuSize
                            buttonSize:kKYCircleMenuButtonSize
                 buttonImageNameFormat:kKYICircleMenuButtonImageNameFormat
                      centerButtonSize:kKYCircleMenuCenterButtonSize
                 centerButtonImageName:kKYICircleMenuCenterButton
       centerButtonBackgroundImageName:kKYICircleMenuCenterButtonBackground]) 
    { 


    } 
    return self;
}

Here, you are doing nothing with the aDecoder object - this contains all of the information from the storyboard (including the segue). Instead you are creating a brand new object, ignoring anything you have set up in the storyboard.

I've had a quick look at the repository and it doesn't seem to be tailored towards use in a storyboard - it implements its own loadView method, it has a designated initialiser and so on. You'd have to play around with it to set those properties after calling [super initWithCoder:aDecoder];, perhaps by pulling out the setup code from the designated initialiser and putting it into a separate method.

Upvotes: 1

Related Questions