简体   繁体   English

我应该为iOS文字冒险应用程序使用哪种类型的segue?

[英]What type of segue should I be using for iOS text adventure app?

So I am currently in the process of building one of my first apps just something simple to practice with a text adventure. 因此,我目前正在构建我的第一批应用程序,只是一些简单的文本冒险练习。 The basic premise is that I want to be able to explain the adventure to the user, present the story and at the end of each scrollable page give them options on how to progress the story each leading to different scenarios. 基本前提是我希望能够向用户解释冒险经历,介绍故事,并在每个可滚动页面的末尾为他们提供有关如何发展故事的选项,每个故事都会导致不同的场景。

I realize I will need to be branching with many different views and segues and I am currently using the present modally segue when transitioning between scenes but I am having this concern that I may end up causing memory issues by doing this? 我意识到我将需要使用许多不同的视图和序列进行分支,并且在场景之间进行转换时我目前正在使用当前的模态序列,但是我担心这样做最终会导致内存问题? From what I have understood in the past is that presenting the next page modally just throws it on top of all the other views is that correct? 根据我过去的理解,以模态呈现下一页只是将其置于所有其他视图之上,是否正确?

Essentially I am just trying to find the best option for transitioning that would be the most efficient as I am still learning the basics. 本质上,我只是在尝试寻找最佳的过渡选项,因为我仍在学习基础知识,因此是最有效的。 Eventually I will be segueing data to the next view as well so at the end of the adventure I can show the user their characteristic values based on their choices. 最终,我还将把数据隔离到下一个视图,因此在冒险结束时,我可以根据用户的选择向用户显示其特征值。 Any thoughts? 有什么想法吗?

PS I think the reason I chose present modally so far was it had the best transition I have found that makes me think of a book (Couldn't find a page flip transition) PS:我认为到目前为止,我之所以选择以模态形式呈现,是因为它具有我发现的最好的过渡效果,使我想起了一本书(找不到页面翻转过渡)

To avoid memory issues, you can use UIViewController 's -transitionFromViewController:toViewController:duration:options:animations:completion: method to swap your controllers instead of a storyboard segue. 为了避免内存问题,可以使用UIViewController-transitionFromViewController:toViewController:duration:options:animations:completion:方法来交换控制器,而不是使用故事板segue。 You will call this method in a base view controller, which presents your visible view controllers, kind of like how a UINavigationController handles this. 您将在基本视图控制器中调用此方法,该视图控制器显示您的可见视图控制器,类似于UINavigationController如何处理此方法。

Alternatively, consider using the UIPageViewController if you want something that looks like a book. 另外,如果您想要看起来像书的东西,请考虑使用UIPageViewController

This depends on where you're presenting the modal. 这取决于您在哪里展示模态。 If you're presenting it from one main view controller, then the previous modal is dismissed. 如果要从一个主视图控制器中显示它,那么将取消先前的模态。

If you were to use other methods, such as a navigation controller push, it would continuously build the view hierarchy and lead to a large memory footprint provided the user dug deep into the adventure. 如果要使用其他方法,例如导航控制器下推,它将连续建立视图层次结构,并导致大量的内存占用,前提是用户需要深入探索冒险。

PS I think the reason I chose present modally so far was it had the best transition I have found that makes me think of a book (Couldn't find a page flip transition) PS:我认为到目前为止,我之所以选择以模态形式呈现,是因为它具有我发现的最好的过渡效果,使我想起了一本书(找不到页面翻转过渡)

Personally, I would only use one view controller and have the view animate using the transitionWithView function. 就个人而言,我只使用一个视图控制器,并使用transitionWithView函数使视图具有动画效果。 This would reduce your memory footprint greatly and provide interesting transitions for the user. 这将大大减少您的内存占用,并为用户提供有趣的过渡。

class func transitionWithView(_ view: UIView,
                 duration duration: NSTimeInterval,
                  options options: UIViewAnimationOptions,
               animations animations: () -> Void,
               completion completion: ((Bool) -> Void)?)

With this, you can provide a wide variety of animation transitions, and even randomize it so there is no idea which one is used and pretty cool functionality. 有了它,您可以提供各种各样的动画过渡,甚至可以将其随机化,因此不知道使用了哪一个以及非常酷的功能。 Here are the transition constants 这是过渡常数

static var TransitionNone: UIViewAnimationOptions { get }
static var TransitionFlipFromLeft: UIViewAnimationOptions { get }
static var TransitionFlipFromRight: UIViewAnimationOptions { get }
static var TransitionCurlUp: UIViewAnimationOptions { get }
static var TransitionCurlDown: UIViewAnimationOptions { get }
static var TransitionCrossDissolve: UIViewAnimationOptions { get }
static var TransitionFlipFromTop: UIViewAnimationOptions { get }
static var TransitionFlipFromBottom: UIViewAnimationOptions { get }

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

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