问题
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:
- 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.
- 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