PushViewController 不工作

发布于 2024-11-18 23:28:43 字数 735 浏览 3 评论 0原文

我有一个应用程序,它有一个名为 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");
}

日志“Button isworking”记录,因此pushViewController行也被触发。

categoryView 是在我的 .h 文件中创建的:

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

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

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

任何帮助将不胜感激! THNX

I have an application which has a view called store. In this view there is a button which loads the DetailView. Problem is that this detailview doesn't load/show. This is the code I use:

-(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");
}

The log "Button is working" logs, so the pushViewController line is also triggered.

categoryView is made in my .h file:

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

In the store.xib there is a UIViewController with an outlet linked to the categoryView outlet.

Somewhere else in my app this is working, and I can't seem to find out why this one isn't

Any help would be appreciated!
THNX

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

仄言 2024-11-25 23:28:43

您是否在 AppDelegate 中分配了 UINavigationController ?

@interface

@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 在整个应用程序中工作正常。

Did you assign the UINavigationController in your AppDelegate?

@interface

@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 works fine then through the whole App.

魔法唧唧 2024-11-25 23:28:43

听起来

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

会显示 navigationController 为零。

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

It sounds like

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

will show that navigationController is nil.

I suggest creating a new project of navigation type and see how this should be setup.

緦唸λ蓇 2024-11-25 23:28:43

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

I have found it. Since I was using a tabbar based app, I needed to change the store tab to Navigation Controller. When I changed it, it worked! Thanks for all your support!!!

空心空情空意 2024-11-25 23:28:43

如果您的视图是基于笔尖的,您需要使用:

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

希望这会有所帮助。

If your view is nib based, you need to use:

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

Hope this helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文