UINavigationController 并呈现一个模态控制器

2023-06-12移动开发问题
3

本文介绍了UINavigationController 并呈现一个模态控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

如果有一个显示 UIScrollView 全屏的 rootViewController.当我点击 UIScrollview 时,我想翻转屏幕并显示一个设置屏幕(它还有第二个屏幕,navigationController 的原因).

If got a rootViewController which display's a UIScrollView full screen. When I tap the UIScrollview, I want to flip the screen and display a settings screen (which also has a second screen, the reason for the navigationController).

我可以在我的 rootViewController 中使用以下代码来显示设置屏幕:<代码>self.navController = [[UINavigationController alloc]initWithRootViewController:self.settingsViewController];

I am able to display the settings screen by using the following code in my rootViewController: self.navController = [[UINavigationController alloc] initWithRootViewController:self.settingsViewController];

并且比:<代码>[self.navController pushViewController:self.settingsViewController 动画:YES];

我的问题是:当我在我的设置视图中完成后,我如何返回到 rootViewController,所以我在其中创建了导航控制器的控制器类因此不在堆栈中.

My question is: When I'm done in my settings view, how do I return back to the rootViewController, so the controller class in which I have created the navigation Controller and is therefore not on the stack.

推荐答案

我采用了 Apple 的解决方案,他们在 节拍器示例.

I've adopted Apple's solution which they use in the Metronome example.

我将 settingsViewController 设置为 navigationController 的 rootViewController.比我显示 navigationController 使用:

I'm setting the settingsViewController as the rootViewController for a navigationController. Than I display the navigationController using:

<代码>[self presentModalViewController:navController Animation:YES];

根据苹果的示例,我创建了 rootViewController 采用的 settingsViewControllerDelegate 接口.接口并不复杂,只是一个委托实例var和一个需要rootViewController实现的回调方法(settingsViewControllerDidFinish).在你调用的那个方法中:

As per apple's example, I've created a settingsViewControllerDelegate interface which the rootViewController adopts. The interface is not complicated, just a delegate instance var and a callback method (settingsViewControllerDidFinish) which needs to be implemented by rootViewController. In that methode you call:

<代码>[自我dismissModalViewControllerAnimated:是];

通过这种方式,我可以使用 navigationController 设置几个设置屏幕,并且可以从 navigationController 返回到 rootViewController.

This way I'm able to have a couple of settings-screens using a navigationController and I'm able to return out of the navigationController back to the rootViewController.

这篇关于UINavigationController 并呈现一个模态控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

The End

相关推荐

硬件音量按钮更改应用程序音量
Hardware Volume buttons change in app volume(硬件音量按钮更改应用程序音量)...
2024-08-12 移动开发问题
10

Cocos2d - 如何检查不同层中对象之间的交集
Cocos2d - How to check for Intersection between objects in different layers(Cocos2d - 如何检查不同层中对象之间的交集)...
2024-08-12 移动开发问题
8

恢复游戏 cocos2d
Resume game cocos2d(恢复游戏 cocos2d)...
2024-08-12 移动开发问题
6

突出显示朗读文本(在 iPhone 的故事书类型应用程序中)
Highlight Read-Along Text (in a storybook type app for iPhone)(突出显示朗读文本(在 iPhone 的故事书类型应用程序中))...
2024-08-12 移动开发问题
9

Cocos2D + 仅禁用 Retina iPad 图形
Cocos2D + Disabling only Retina iPad Graphics(Cocos2D + 仅禁用 Retina iPad 图形)...
2024-08-12 移动开发问题
10

正确的 cocos2d 场景重启?
Proper cocos2d scene restart?(正确的 cocos2d 场景重启?)...
2024-08-12 移动开发问题
7