简体   繁体   English

iOS Multiview应用

[英]iOS Multiview App

I am trying to build a multiview app ie based on some gestures, new views are shown, removed etc. 我试图建立一个多视图的应用程序,即基于一些手势,显示新视图,删除等。

I have found 3 ways to do so - 我发现了3种方法-

  1. [self.view insertSubview:newViewController.view atIndex:3];
  2. Using UINavigationController 使用UINavigationController
  3. Finally using modalViewController - [self presentModalViewController:newViewController animated:YES]; 最后使用modalViewController- [self presentModalViewController:newViewController animated:YES];

First off, in second method, can I use this controller without UINavigationTabBar ? 首先,在第二种方法中,可以在没有UINavigationTabBar情况下使用此控制器吗? I have a set of custom UIView objects which I want to push & pop from Screen. 我有一组要从屏幕推送和弹出的自定义UIView对象。 I dont want the ugly Apple's NavigationBar at top (or bottom). 我不希望丑陋的Apple的NavigationBar位于顶部(或底部)。 I will provide custom buttons based on which [self.navigationController popViewControllerAnimated] should occur. 我将基于应出现的[self.navigationController popViewControllerAnimated]提供自定义按钮。 Can this be possible? 可以吗?

Also, Which of these techniques is best? 另外,以下哪种技术最好? In terms of usage & code maintenance, memory usage etc. 在使用和代码维护,内存使用等方面

In terms of usage & code maintenance, memory usage etc., there's little doubt that UINavigationController is the best fit. 在用法和代码维护,内存使用等方面,毫无疑问, UINavigationController是最合适的。 It's been optimized for exactly the sort of thing you're doing. 它已针对您正在做的事情进行了优化。 And because you push and pop UIViewController s from it (not just UIView s), views that are not currently displayed on screen can be automatically released to free up memory by the OS. 并且由于您从其中推入并弹出UIViewController (而不仅仅是UIView ),因此OS可以自动释放当前未显示在屏幕上的视图,以释放内存。

Can you use a navigation view without the bar across the top? 您是否可以使用导航视图而顶部没有横条? I think maybe you should RTFM. 我认为也许您应该使用RTFM。 Specifically, -setNavigationBarHidden:animated: 具体来说, -setNavigationBarHidden:animated:

That said, UINavigationController is not particularly flexible at doing things it wasn't designed to do. 就是说, UINavigationController在执行原本不打算做的事情时并不是特别灵活。 In particular, it's opinionated about the transitions it uses to animate between view controllers on its stack. 特别是,对于用于在其堆栈上的视图控制器之间进行动画处理的过渡,人们有很多看法。

You might have some luck pushing and popping sans animation (by passing NO to the animated: parameter of those methods), and having a delegate set up to handle -navigationController:willShowViewController:animated: . 您可能会有一些运气来推动和弹出san动画(通过将NO传递给那些方法的animated:参数),并设置一个委托来处理-navigationController:willShowViewController:animated: You could in theory add a CATransition to the root view's animations there. 从理论上讲,您可以在CATransition向根视图的动画添加CATransition But anything much more complicated than that (a view that tracks your finger while sliding on to the screen, etc.) and you'll probably have to write your own controller and manage your own views. 但是任何比这更复杂的事情(一个在滑到屏幕上时跟踪手指的视图等),您可能必须编写自己的控制器并管理自己的视图。

But you should still read Apple's View Controller Programming Guide for iOS and the NSNavigationManager specs until you grok them in their fullness. 但是您仍然应该阅读Apple的《 iOS View Controller编程指南》NSNavigationManager规范,直到完全了解它们为止。 It'd be hard to find a better pattern to base your design around. 很难找到更好的模式来进行设计。

Second one UINavigationController. 第二个UINavigationController。 And yes you can use your custom navigation bar. 是的,您可以使用自定义导航栏。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM