Storyboard - How to design offscreen content?

和自甴很熟 提交于 2019-12-22 11:33:55

问题


This question gives a basic description of what I'm trying to do. Basically, I am animating offscreen content into view. There are several subviews I animate in this way, but they never occupy the same space at the same time. Now I'm having trouble being able to design content that starts offscreen. I have tried two ways, neither satisfactory:

  1. I stacked the subviews on top of each other where they will be viewed, and set the position to offscreen in the User Defined Runtime Attributes. I don't like this way, because I can't easily toggle which view I'm looking at, so designing is tough.
  2. I initially positioned the subviews off screen. This is annoying because you have to reposition a subview back onscreen before you can see it to design it.

How would this be done? How have you done accomplished something similar in the past?


回答1:


I'm not quite sure I'm getting it but I'll take a shot here.

So in storyboard you can create a view that is not connected or segued to the root view - you just drag out a viewController object from the libray and design it as you want. It doesn't have to be on top of anything or contained within the root viewController view.

Once you have this you can instantiate it when you need to with:

[[UIStoryboard storyboardWithName:@"MainStoryboard_iPad" bundle:NULL] instantiateViewControllerWithIdentifier:@"someName"];

From there you can position it and set up a UIView animation to bring it into view.

Or maybe I am not getting it...

EDIT (fixed error):

myViewController = [[UIStoryboard storyboardWithName:@"MainStoryboard_iPad" bundle:NULL] instantiateViewControllerWithIdentifier:@"someName"];

[self addChildViewController:myViewController];
[self.view addSubview:myViewController.view];

//do the animation on screen


来源:https://stackoverflow.com/questions/9781056/storyboard-how-to-design-offscreen-content

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!