Basic View Switch Code Crashes iPhone simulator

Posted by Ouija on Stack Overflow See other posts from Stack Overflow or by Ouija
Published on 2011-06-23T23:18:01Z Indexed on 2011/06/24 0:22 UTC
Read the original article Hit count: 157

Filed under:
|
|
|

I've been trying to switch two views from two separate view controllers for a while and it never works, the simulator always crashes to the home screen. I'm using Xcode 3.2.5 and this is my code -

SwitchViewsViewController.h

#import <UIKit/UIKit.h>
#import "SecondViewController.h"

@interface SwitchViewsViewController : UIViewController {
}
-(IBAction)pushButton;
@end

SwitchViewsViewController.m

#import "SwitchViewsViewController.h"
#import "SecondViewController.h"

@implementation SwitchViewsViewController

-(IBAction)pushButton {
    SecondViewController *screen = [[SecondViewController alloc] initWithNibName:nil bundle:nil    
    screen.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    [self presentModalViewController:screen animated:YES]
    [screen release];
}

SecondViewController.h

#import <UIKit/UIKit.h>

@interface SecondViewController : UIViewController {
}
-(IBAction)pushBack;
@end

SecondViewController.m

#import "SecondViewController.h"

@implementation SecondViewController

-(IBAction)pushBack{
    [self dismissModalViewControllerAnimated:YES];
}

In interface builder, all i've done is linked the file's owner classes and the buttons. Also made the SwitchViewsViewController load first, and not MainWindow. Everything builds but when I try to run the app it crashes and sends it to the home screen. Can anyone help me with this?

© Stack Overflow or respective owner

Related posts about iphone

Related posts about xcode