如果有一个显示 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 并呈现一个模态控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!