iPhone 导航控制器不显示

发布于 2024-09-24 03:17:45 字数 1826 浏览 0 评论 0原文

我的导航视图有一个非常奇怪的行为。我想要的是,从我的主视图中,用户可以触摸一个按钮,这会将他引导到具有应用程序设置的视图。

下面是负责导航的代码:

AppDelegate.h

    @interface AppDelegate : NSObject  {
    UIWindow *window;
    ViewController *viewController; // My Main View Controller
    UINavigationController *navigationController; } 

    @property (nonatomic, retain) IBOutlet UIWindow *window;
    @property (nonatomic, retain) IBOutlet ViewController *viewController;
    @property (nonatomic, retain) IBOutlet UINavigationController *navigationController;

AppDelegate.m

@synthesize viewController;
@synthesize window;
@synthesize navigationController;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

    [window addSubview:viewController.view];
    [window addSubview:navigationController.view];
    [window makeKeyAndVisible];
    return YES;
}

viewController.h

#import 
#import "optionsViewController.h" // the 'settings' view controller
@class AppDelegate;

@interface ViewController : UIViewController {
    AppDelegate *appDelegate;

viewController.m

- (IBAction)showOptionsViewController:(UIBarButtonItem *)sender {
//  optionsController.theSubjectID = self.theSubjectID;
//  [self presentModalViewController:self.optionsController animated:YES];


    optionsViewController *optionsController= [[optionsViewController alloc] initWithNibName:@"optionsViewController" bundle:nil];
    optionsController.theSubjectID = self.theSubjectID;
    [self.navigationController pushViewController:optionsController animated:YES];
    [optionsController release];

}

我的 optionsController 是一个“普通”UIViewController。正如您所看到的,我是否将 optionsController 的负载从模式更改为导航。难道我在这里错过了什么吗?

感谢您提前提供任何提示。

干杯,雷内

I have a very strange behaviour of my navigation view. What I want is, that from my main view, the user can touch a button, which leads him to the view with the application settings.

Here is the code, responsible for the navigation:

AppDelegate.h

    @interface AppDelegate : NSObject  {
    UIWindow *window;
    ViewController *viewController; // My Main View Controller
    UINavigationController *navigationController; } 

    @property (nonatomic, retain) IBOutlet UIWindow *window;
    @property (nonatomic, retain) IBOutlet ViewController *viewController;
    @property (nonatomic, retain) IBOutlet UINavigationController *navigationController;

AppDelegate.m

@synthesize viewController;
@synthesize window;
@synthesize navigationController;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    

    [window addSubview:viewController.view];
    [window addSubview:navigationController.view];
    [window makeKeyAndVisible];
    return YES;
}

viewController.h

#import 
#import "optionsViewController.h" // the 'settings' view controller
@class AppDelegate;

@interface ViewController : UIViewController {
    AppDelegate *appDelegate;

viewController.m

- (IBAction)showOptionsViewController:(UIBarButtonItem *)sender {
//  optionsController.theSubjectID = self.theSubjectID;
//  [self presentModalViewController:self.optionsController animated:YES];


    optionsViewController *optionsController= [[optionsViewController alloc] initWithNibName:@"optionsViewController" bundle:nil];
    optionsController.theSubjectID = self.theSubjectID;
    [self.navigationController pushViewController:optionsController animated:YES];
    [optionsController release];

}

My optionsController is a 'normal' UIViewController. As you see did I change the load of the optionsController from modal to navigation. Could it be, that I missed something here?

Thanks for any hints in advance.

Cheers, René

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

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

发布评论

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

评论(1

一袭水袖舞倾城 2024-10-01 03:17:45

如果在将其添加为子视图之前需要分配/初始化它,您是否在 Interface Builder 中连接了它?

Have you connected it up in Interface Builder if not you need to alloc/init it before you add it as a subview?

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