2

I have 2 container view controllers on my main screen, one which acts as a global toolbar at the top. This is great most of the time, but I need to animate this off screen, to give more room for the user to see lots of information on the screen. Is this possible? I've been looking at the documentation, but I'm not sure if I need to use the transformation animation, or change the frame/bounds. Any suggestions would be grateful.

Alex
  • 3,031
  • 6
  • 34
  • 56
  • Blamo! http://developer.apple.com/library/ios/documentation/uikit/reference/uiview_class/uiview/uiview.html#//apple_ref/occ/clm/UIView/animateWithDuration:delay:options:animations:completion: – JoshRagem Jan 24 '13 at 00:34

1 Answers1

1

You should just be able to change the frame/bounds in a standard UIView animation (block or otherwise). No need to reference the "contained" views.

Update: Here's a block animation example.

[UIView animateWithDuration:1.0f
                 animations:^{
                     view1.frame = CGRectMake(blah...);
                 }
                 completion:^(BOOL finished){
                     // do something here if you wish.
                 }];
livingtech
  • 3,570
  • 29
  • 42
  • Often it's useful to put a container view on the parent's view, and then put the child controller's view(s) on that. If so, you need to make sure that you have the autosizing mask or autolayout constraints set up so that as the container view, `view1` in your example, changes, the child's view does, too. But with that one caveat, I agree with your answer. – Rob Jan 24 '13 at 00:40
  • I didn't mention this in my answer, (because it's not specifically relevant to the question), but it used to be the case that apple recommended strongly that a single `UIViewController` subclass control the entire screen. They specifically recommended against this scenario. But I'm 90% sure there are now some UIKit VC subclasses that directly violate this maxim (there definitely are in iPad land anyway). – livingtech Jan 24 '13 at 00:46
  • This was Apple's counsel pre-iOS 5, but with the introduction of custom containers, they no longer take this position. They only insist that (a) if you have multiple controllers for multiple portions of the screen that you correctly use [all of the custom container methods](http://developer.apple.com/library/ios/documentation/uikit/reference/UIViewController_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006926-CH3-SW81) and (b) they suggest you only use custom containers when standard ones will not suffice. – Rob Jan 24 '13 at 06:09
  • And in response to your second observation that there are standard built-in container controllers, Apple provides some [examples of built-in container controllers](http://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/CreatingCustomContainerViewControllers/CreatingCustomContainerViewControllers.html#//apple_ref/doc/uid/TP40007457-CH18-SW8). – Rob Jan 24 '13 at 06:13