我一直试图从两个单独的视图控制器切换两个视图一段时间,它永远不会工作,模拟器总是崩溃到主屏幕。我使用的Xcode 3.2.5,这是我的代码 -基本视图开关代码崩溃iPhone模拟器
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];
}
在Interface Builder中,所有我所做的就是链接的文件的所有者类和按钮。首先加载SwitchViewsViewController,而不是MainWindow。一切都在建立,但是当我尝试运行应用程序时,它会崩溃并将其发送到主屏幕。谁能帮我这个?
我试过了,仍然崩溃:( – Ouija
等一下,当你按下按钮或者它启动时应用程序崩溃了吗? –
崩溃在按钮上,但我修复了它,查看没有链接到文件老板 – Ouija