Question

I try this:

ViewController.h

@class SecondView;

@interface Introduccion : UIViewController{

    SecondView *second;
}

-(IBAction)AnimatecreditsPage:(id)sender;

@end

ViewController.m

-(IBAction)AnimatecreditsPage:(id)sender{

    second = [[SecondView alloc]initWithNibName:@"SecondView" bundle:nil];

    second.modalTransitionStyle = UIModalTransitionStylePartialCurl;
    [self presentModalViewController:second animated:YES];

}

Im using Storyboards, and i already linked my viewcontroller with the corresponding classes, when i press the button, the iphone simulator just crash.. im using a navigation controller and tab bar controller.

Image of the viewcontroller

THANKS!! :) Please Help Me.

Was it helpful?

Solution

The way you're trying is crashing because you're pointing to a xib that doesn't exist. Since with storyboards you can have multiple view controllers you have to add an identifier to the view controller you wish to use in the attributes inspector section of interface builder. This then allows you to use the following code to programmatically instantiate what ever view controller in your storyboard has the ID you specify.

second = [self.storyboard instantiateViewControllerWithIdentifier:@"someID"];

Instead of:

second = [[SecondView alloc]initWithNibName:@"SecondView" bundle:nil];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top