11

我有一个应用程序,它有一个名为 store 的视图。在此视图中,有一个加载 DetailView 的按钮。问题是这个细节视图没有加载/显示。这是我使用的代码:

-(void)knop:(id)sender{
    categoryView = [[CategoryView alloc] init];
    //show detail view using buttonDetail...
    [self.navigationController pushViewController:categoryView animated:YES];
    [categoryView release];
    NSLog(@"Button is working");
}

日志“按钮正在工作”日志,因此 pushViewController 行也被触发。

categoryView 是在我的 .h 文件中制作的:

 CategoryView IBOutlet *categoryView;
}
@property (nonatomic, retain) IBOutlet CategoryView *categoryView;

在 store.xib 中有一个 UIViewController,它的出口链接到 categoryView 出口。

在我的应用程序的其他地方这是有效的,我似乎无法找出为什么这个不是

任何帮助,将不胜感激!THNX

4

4 回答 4

12

您是否在 AppDelegate 中分配了 UINavigationController?

@界面

@property (nonatomic, retain) IBOutlet RootViewController *rootViewController;
@property (nonatomic, retain) IBOutlet UINavigationController *navigationController;

@implementation didFinishLaunchingWithOptions

rootViewController = [[RootViewController alloc] initWithNibName:@"RootView" bundle:nil];
navigationController = [[UINavigationController alloc] initWithRootViewController:rootViewController];

[window addSubview:navigationController.view];
[self.window makeKeyAndVisible];

pushViewController 工作正常,然后通过整个应用程序。

于 2011-07-06T13:48:07.717 回答
10

这听起来像

NSLog(@"nav controller = %@", self.navigationController); 

将显示 navigationController 为零。

我建议创建一个导航类型的新项目,看看应该如何设置。

于 2011-07-06T12:30:41.517 回答
3

我找到了。由于我使用的是基于标签栏的应用程序,因此我需要将商店标签更改为导航控制器。当我改变它时,它起作用了!感谢您的支持!!!

于 2011-07-06T20:27:26.050 回答
1

如果您的视图是基于 nib 的,则需要使用:

categoryView = [[CategoryView alloc] initWithNibName:nibName bundle:nibBundle];

希望这可以帮助。

于 2011-07-06T13:12:19.297 回答