Nayan
Nayan

Reputation: 3014

What is a difference between self.view and self.view .superview of a rootViewController?

I have a view controller which is assigned as a rootViewController like below :

self.viewCntrl = [[ViewController alloc]initWithNibName:@"ViewController" bundle:nil];
self.window.rootViewController = self.viewCntrl;

And in the same view controller i have a button and i am performing transition animation on button click like this:

[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view.superview cache:YES];

but it not works when i write like this:

[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];

As here self is a ViewController's object, the ViewController which is nothing but assigned to self.window.rootViewController. So why it takes self.view.superview instead of self.view to animate?

Upvotes: 0

Views: 1181

Answers (1)

sergio
sergio

Reputation: 69027

Depending on the kind of animation you are trying to execute, possibly the answer is here:

If you want to change the appearance of a view during a transition—for example, flip from one view to another—then use a container view, an instance of UIView, as follows:

  1. Begin an animation block.

  2. Set the transition on the container view.

  3. Remove the subview from the container view.

  4. Add the new subview to the container view.

  5. Commit the animation block.

Upvotes: 1

Related Questions