iPhone 导航控制器不显示
我的导航视图有一个非常奇怪的行为。我想要的是,从我的主视图中,用户可以触摸一个按钮,这会将他引导到具有应用程序设置的视图。
下面是负责导航的代码:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果在将其添加为子视图之前需要分配/初始化它,您是否在 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?