如何使用隐藏的导航栏将导航控制器正确添加到我的搜索视图

时间:2011-09-05 07:07:00

标签: iphone ios ios4 uiviewcontroller uinavigationcontroller

当我的应用程序启动时,用户在我的应用程序启动时看到的第一个屏幕(视图)是没有任何导航的搜索表单。搜索过程完成后,导航将显示,并且结果已准备好显示。我坚持的地方是让它与导航控制器一起工作的正确方法。

因此,假设应用名称为RealEsateProperties

在RealEsatePropertiesAppDelegate.h中:

#import <UIKit/UIKit.h>

@class RealEsatePropertiesViewController;

@interface RealEsatePropertiesAppDelegate : NSObject <UIApplicationDelegate> 
{
        UINavigationController *ListingNav;
}

@property (nonatomic, retain) IBOutlet UIWindow window;

@property (nonatomic, retain) RealEsatePropertiesViewController *viewController;

// Then I added this line for the navigation
@property (nonatomic, retain) UINavigationController *ListingNav;


@end

并在RealEsatePropertiesAppDelegate.m中:

#import "RealEsatePropertiesAppDelegate.h"
#import "RealEsatePropertiesViewController.h"

@synthesize window=_window;

@synthesize window=_viewController;

@synthesize ListingNav;

@implementation RealEsatePropertiesAppDelegate

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

self.window.rootViewController = self.viewController;

// Iadded the following 4 lines to try making the navigation thing work without showing any navigation bar on the first screen (that is the search form)
self.ListingNav = [[UINavigationController alloc] initWithRootController:self.viewController];
self.ListingNav.navigationBarHidden = YES;
[self.window addSubView:ListingNav.view];

[self.window makeKeyAndVisible];
return YES;
}

@end

我做错了吗?

求助,

的Stephane

1 个答案:

答案 0 :(得分:1)

您需要创建/分配您的RealEsatePropertiesViewController吗?

viewController = [[RealEsatePropertiesViewController alloc] init];