【发布时间】:2011-06-23 23:18:01
【问题描述】:
一段时间以来,我一直在尝试从两个单独的视图控制器切换两个视图,但始终无法正常工作,模拟器总是崩溃到主屏幕。我正在使用 Xcode 3.2.5,这是我的代码 -
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];
}
在界面生成器中,我所做的只是链接文件的所有者类和按钮。还首先加载了 SwitchViewsViewController,而不是 MainWindow。一切都建立了,但是当我尝试运行应用程序时,它崩溃并将其发送到主屏幕。谁能帮我解决这个问题?
【问题讨论】: