帮助导航控制器、窗口和子视图!

发布于 2024-09-08 14:58:25 字数 949 浏览 1 评论 0原文

我的第一个 xib 在 MainWindow.xib 中包含一个带有类似跳板的界面的 ScrollView:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {   
     navController = [[UINavigationController alloc] init];

[navController setNavigationBarHidden:YES]; [窗口addSubview:navController.view]; [窗口 sendSubviewToBack:navController.view];当

单击按钮时,FirstViewController 会显示一个表格视图和一个导航控制器:

    - (void) buttonPushed:(id)sender {
       FirstViewController *firstViewController = [[FirstViewController alloc] init];
       [navController pushViewController:firstViewController animated:YES];
[firstViewController release];


[window addSubview:navController.view]; }

当我单击导航控制器中的后退按钮返回跳板时,我得到了跳板 xib,但对顶部导航栏的触摸没有响应!

- (void)goHome:(id) sender { 
[self.view removeFromSuperview];

如何在不将导航栏堆叠在顶部的情况下返回跳板屏幕(mainwindow.xib)并响应触摸?

my first xib contains a ScrollView with a springboard like interface in MainWindow.xib:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {   
     navController = [[UINavigationController alloc] init];

[navController setNavigationBarHidden:YES];
[window addSubview:navController.view];
[window sendSubviewToBack:navController.view]; }

When a button is clicked the FirstViewController appears with a tableview and a navigation controller:

    - (void) buttonPushed:(id)sender {
       FirstViewController *firstViewController = [[FirstViewController alloc] init];
       [navController pushViewController:firstViewController animated:YES];
[firstViewController release];


[window addSubview:navController.view]; }

When I click the back button in Navigation Controller to go back to springboard, I get the springboard xib, but unresponsive to touches with a Navigation Bar on top!

- (void)goHome:(id) sender { 
[self.view removeFromSuperview];

How can I go back to springboard screen (mainwindow.xib) without having the navigation bar stacked on top, and be responsive to touches ?

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

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

发布评论

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

评论(3

他是夢罘是命 2024-09-15 14:58:25

为什么不将跳板视图设置为导航控制器的根视图控制器并删除窗口中的任何 UI?

我认为窗口不应该有任何 UI 元素接受添加到其中的视图控制器的视图(通过导航控制器或选项卡栏控制器)。

这样,您就不必重新发明轮子来从跳板视图加载第一个视图,并且后退按钮将正常工作。

您可以在根视图控制器(跳板视图的视图控制器)的viewDidLoad方法中将navigationBarHidden属性设置为false。

Why don't you set the springboard view to be the root view controller of your navigation controller and get rid of any UI in the window?

I think that the window shouldn't have any UI elements accept view of view controllers that are added to it (by navigation controller or by tab bar controller).

This way you won't have to reinvent the wheel for the first view to load from the springboard view and the back button will work properly.

You can set the navigationBarHidden property to false in the viewDidLoad method of the root view controller (the view controller of the springboard view).

压抑⊿情绪 2024-09-15 14:58:25

您是否尝试调用 [navController setNavigationBarHidden:YES];在你的主视图 viewWillAppear 回调中?

Did you try calling [navController setNavigationBarHidden:YES]; in your mainview viewWillAppear callback ?

温柔一刀 2024-09-15 14:58:25
- (void)applicationDidFinishLaunching:(UIApplication *)application

{

UIViewController *rootController = [[MyRootViewController alloc] init];

navigationController = [[UINavigationController alloc]

                            initWithRootViewController:rootController];

[rootController release];



window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

[window addSubview:navigationController.view];

[window makeKeyAndVisible];

}

- (void)applicationDidFinishLaunching:(UIApplication *)application

{

UIViewController *rootController = [[MyRootViewController alloc] init];

navigationController = [[UINavigationController alloc]

                            initWithRootViewController:rootController];

[rootController release];



window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];

[window addSubview:navigationController.view];

[window makeKeyAndVisible];

}

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