gpt4 book ai didi

objective-c - UINavigationController 仅显示一半的导航栏

转载 作者:行者123 更新时间:2023-11-29 04:53:53 28 4
gpt4 key购买 nike

我创建了一个非常简单的应用程序,使用 UINavigationController 作为根 Controller ,但是当我运行它时,只显示导航栏的一半(左侧)。为什么是这样?这看起来很奇怪 - 如果我做错了什么,你会认为它根本不会显示,但实际上只显示了一半!

Controller 看起来像这样:

@interface RootController : UINavigationController { 
UIWebView* webView;
NSMutableString *htmlString;
}

具有相应的@property声明和@synthesize。

我没有为 View Controller / View 使用任何.nib。应用程序委托(delegate)是:

- (BOOL)application:(UIApplication *)application  didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
RootController* theRVC = [[RootController alloc] init];
self.window.rootViewController = theRVC;
[theRVC release];
[self.window makeKeyAndVisible];
return YES;
}

Controller 有以下相关代码:

- (void)loadView
{
webView = [[UIWebView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
self.view = webView;
[webView release];
}

- (void)viewDidLoad
{
[super viewDidLoad];
}

最佳答案

您不应该从 UINavigationController 派生。

相反,从 UIViewController 派生您的 RootController 类。然后,在应用程序委托(delegate)中,您初始化一个传入 RootController 的 UINavigationController,并将其设置为 Windows rootViewController。

- (BOOL)application:(UIApplication *)application  didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
RootController* theRVC = [[RootController alloc] init];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:theRVC];
self.window.rootViewController = navController;
[theRVC release];
[navController release];
[self.window makeKeyAndVisible];
return YES;
}

关于objective-c - UINavigationController 仅显示一半的导航栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8351721/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com