我想在View Controller类的按钮单击选项中导航类。请给出这样做的方法。我使用给定的以下代码在按钮单击时执行此操作。
- (void)buttonAction {
Status *status = [[Status alloc] init];
[self.navigationController pushViewController:status animated:YES];
}
// Status is a UIViewController subclass
答案 0 :(得分:1)
(void)buttonAction
{
Status *status = [[Status alloc]init];//this is not proper
[self.navigationController pushViewController:status animated:YES];
}
你必须使用
(void)buttonAction
{
Status *status = [[Status alloc]initWithNibName:@"YourNib" bundle:nil];
[self.navigationController pushViewController:status animated:YES];
[status release];
}
这里你的笔尖是你想要显示的xib的名字。
编辑:
现在您的应用程序是基于视图的
(无效)buttonAction { 所以制作appDelegate类的对象(suppos objApp) 现在,
Status *status = [[Status alloc]initWithNibName:@"YourNib" bundle:nil];
[objApp.window addSubview:status.view];
[status release];
}