Re: transitionWithView:duration:options:animations:completion: still defeats me
Re: transitionWithView:duration:options:animations:completion: still defeats me
- Subject: Re: transitionWithView:duration:options:animations:completion: still defeats me
- From: Roland King <email@hidden>
- Date: Tue, 10 May 2011 18:40:31 +0800
On 10-May-2011, at 3:12 AM, Matt Neuburg wrote:
>
>> Date: Mon, 09 May 2011 21:43:38 +0800
>> From: Roland King <email@hidden>
>> Subject: transitionWithView:duration:options:animations:completion:
>> still defeats me
>>
>> I seem to have a lot of trouble with this method! A few months ago I had my own custom drawRect: and that was messing it up, this time I just have a simple UIView with some controls on it, nothing clever. One of the controls is given by the property 'complexity'. What I want is for my UIView to rotate and show up with/without that control. However whatever I have tried all that happens is the control instantly disappears or reappears, no transition at all. Here's the code ..
>>
>> [ UIView transitionWithView:factorsView
>> duration:2.0f
>> options:( UIViewAnimationTransitionFlipFromRight | UIViewAnimationOptionAllowAnimatedContent )
>> animations:^{ [ [ factorsView complexity] setHidden:![ [ factorsView complexity ] isHidden ] ]; }
>> completion:NULL
>> ];
>>
>> factorsView is the UIView subclass and it's displayed and it's on screen.
>>
>> I've tried with and without the AllowAnimatedContent option. The factorsView never rotates, it stays right where it is, and the complexity subview just winks in and out of existence.
>
> The key thing is to ask for the factorsView to be redrawn. Otherwise you're not doing anything to it that can trigger animation. In other words, the animation block should consist of [factorsView setNeedsDisplay].
>
> http://www.apeth.com/iOSBook/ch17.html#_view_animation
>
> m.
In this case it turned out to be something simpler. There's a difference between 'UIViewAnimationTransitionFlipFromRight' and 'UIViewAnimationOptionTransitionFlipFromRight'. The former is for setAnimationTransition:forView:cache: the latter is for the transitionWithView:duration:options:animations:completion: method. The compiler doesn't tell one enum from another and neither it seems can my brain at 11pm. Switching to the correct constant everything worked.
Thanks as ever - I like the look of your book by the way, nice examples and it all goes in a sensible order. _______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden