问题描述
||
我有一个MainWindow.xib文件。我在第一个MainWindow.xib文件屏幕上有一个标签和一个按钮。我有secondview.xib文件,如果用户单击主屏幕按钮,我想加载secondview.xib文件。我编写了一种通过以下代码加载Secondview的方法。
self.second=[[[SecondWindow alloc]initWithNibName:@\" HarbourFront\" bundle:nil]autorelease];
从MainWindow屏幕。
我的接口声明是,
#import \"SecondWindow.h\"
@interface TrainingProject_1AppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
SecondWindow *second;
}
@property (nonatomic,retain) IBOutlet UIWindow *window;
@property (nonatomic,retain) SecondWindow *second;
-(IBAction) listTableView:(id) sender;
@end
// DeFinition in \".m\" file
@synthesize second;
-(IBAction) listTableView:(id) sender {
NSLog(@\"event called\");
self.second=[[[SecondWindow alloc]initWithNibName:@\" HarbourFront\" bundle:nil]autorelease];
}
我检查了该方法正在被调用,但是SecondWindow没有加载。
如何加载SecondWindow?
解决方法
试试这个代码:
self.second=[[[SecondWindow alloc]initWithNibName:@\" HarbourFront\" bundle:nil]autorelease];
[self .navigationController pushViewController:self.second animated:YES];
希望对您有帮助。
, 只需将此行[self.window addSubView:self.second.view];在self.second = [[[SecondWindow alloc] initWithNibName:@ \“ HarbourFront \” bundle:nil] autorelease行下面;