0
我无法加载按钮按下时的下一个视图。我创建了一个按钮,并将checkButtonPress操作附加到IB中的按钮。但是当我按下模拟器上的按钮时,下一个视图(ViewOne.xib)不会加载。当我试图调试代码时;它打印NSLog(@“View One”);写在下面的if语句中,这意味着代码已到达该点,但下一个视图未加载。我已经创建了ViewOne .h,.m .xib文件。以下是写在check1ViewController.m执行文件中的代码:无法在按钮上加载视图按下iPhone
#import "check1ViewController.h"
#import "ViewOne.h"
@implementation check1ViewController
-(IBAction) checkButtonPress: (id) sender{
int button = [sender tag];
if(button==1)
{
NSLog(@"View One");
ViewOne *tempObj = [[ViewOne alloc]initWithNibName:@"ViewOne" bundle:nil];
[self.navigationController pushViewController:tempObj animated:YES];
[tempObj release];
}
else if(button==2)
{
NSLog(@"View Two");
}
}
/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) {
// Custom initialization
}
return self;
}
*/
/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/
/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
}
*/
- (void)dealloc {
[super dealloc];
}
@end
的代码运行正常,没有错误或警告。
如果我缺少的IB或代码写入任何部分或确实需要重写任何方法中的任何文件的......还是我的任何其他方法
前放错IBAction为任何建议对不起,但我是新的iPhone开发,所以不知道我做错了什么?
在此先感谢
你有导航控制器设置正确吗?检查它是否不在该地方 – Vladimir 2010-12-08 12:51:05
我在创建项目时选择了基于Window的模板,并且前面提到的 - (IBAction)checkButtonPress方法是唯一编写的代码,用于加载预期的下一个视图。对不起......只是想知道我错过了什么 – Prazi 2010-12-08 12:59:11