I’ve created a single UIView (We’ll call it “Person”) in an UIViewController that accepts an NSArray of people and simply displays information about them.
This Controller is instanced and loaded as a subview from a variety of places (searches, building layouts..etc…) so it must be self-contained, with none of the code coming from the parent/superview.
Right now, on a left or right swipe, I’m incrementing/decrementing in my array and updating a variety of labels.
This works fine, but isn’t very ascetically pleasing. I’m wondering if its possible to create another instance of my view, reload my labels and then switch to it with some animation?
I apologize if I’m going about this the wrong way, I’m attempting to teach myself Objective-C.
Thanks,
Ben
Yes, what you are describing is possible to do. Whether or not it is the best way to do what you want probably depends on the type of effect you are looking for.
For example, you do have the option of animating the data changes within the view itself as well. For example, if you animate fading all of your labels out, changing their values, and then fading the labels back in, this effect should look similar to the effect of transitioning between two instances of the same, larger view and has the advantage of being more memory-efficient, since you don’t have to create an entire duplicate view.
It will likely be much simpler to code as well, since it can keep everything inside of that single UIView file. Your proposed solution would likely require some coding on the level of the view controllers.
I would look at the UIView animation properties for starters, as they are relatively simple. Some more complex things can be done with the subclasses of CAAnimation.