Calling -display fixed the problem, works perfectly. Thanks!

On 2011-06-18, at 9:25 AM, Houdah - ML Pierre Bernard wrote:

> Try calling -display after -setWantsLayer:
> 
> The view needs to be drawn once into the layer before being able to animate.
> 
> Another way of achieving the desired result is to draw the initial and target 
> view into images and then animate the swapping of image views.
> 
> Best,
> Pierre Bernard
> Houdah Software s.à r.l.
> 
> On Jun 18, 2011, at 6:33 AM, Indragie Karunaratne wrote:
> 
>> Super late reply here, but I just tried that and it still doesn't work. It 
>> seems to work every now and then randomly but other times it doesn't work at 
>> all. Sounds like some sort of timing issue.
>> 
>> On 2011-05-18, at 1:04 AM, Josh Abernathy wrote:
>> 
>>> Try doing the animation one runloop after calling -setWantsLayer:, kinda 
>>> like this (typed in Mail):
>>> 
>>> - (void)doAnimation {
>>>  [parentView setWantsLayer:YES];
>>>  [self performSelector:@selector(noSeriouslyDoTheAnimation) withObject:nil 
>>> afterDelay:0];
>>> }
>>> 
>>> - (void) noSeriouslyDoTheAnimation {
>>>  CATransition *transition = [CATransition animation];
>>>  transition.type = kCATransitionPush;
>>>  transition.subtype = kCATransitionFromLeft;
>>>  transition.timingFunction = [CAMediaTimingFunction 
>>> functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
>>>  [CATransaction begin];
>>>  [CATransaction setCompletionBlock:^(void) {
>>>     [parentView setWantsLayer:NO];
>>>  }];
>>>  [parentView setAnimations:[NSDictionary dictionaryWithObject:transition 
>>> forKey:@"subviews"]];
>>>  [[parentView animator] replaceSubview:firstView with:secondView];
>>>  [CATransaction commit];
>>> }
>>> 
>>> 
>>> On May 17, 2011, at 7:59 PM, Indragie Karunaratne wrote:
>>> 
>>>> Hi all,
>>>> 
>>>> I'm trying to use CATransition in my app to provide an animated slide 
>>>> transition when swapping views. I don't want to permanently layer back my 
>>>> views because they cause various glitches (no subpixel antialiasing, 
>>>> resize issues when backed with a CATiledLayer, etc.) To get around this, I 
>>>> want to temporarily layer back my view, run the animation, and then 
>>>> disable layer backing after the animation completes. This is my code thus 
>>>> far:
>>>> 
>>>> CATransition *transition = [CATransition animation];
>>>> transition.type = kCATransitionPush;
>>>> transition.subtype = kCATransitionFromLeft;
>>>> transition.timingFunction = [CAMediaTimingFunction 
>>>> functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
>>>> [parentView setWantsLayer:YES];
>>>> [CATransaction begin];
>>>> [CATransaction setCompletionBlock:^(void) {
>>>>     [parentView setWantsLayer:NO];
>>>> }];
>>>> [parentView setAnimations:[NSDictionary dictionaryWithObject:transition 
>>>> forKey:@"subviews"]];
>>>> [[parentView animator] replaceSubview:firstView with:secondView];
>>>> [CATransaction commit];
>>>> 
>>>> With this code, the animation doesn't run (the views just get swapped 
>>>> without animation but the completion block is still called). The problem 
>>>> seems to be the fact that I'm calling -setWantsLayer: immediately before 
>>>> the animation begins. If I call this method in -awakeForNib, the animation 
>>>> will run. I'm thinking that this might be some sort of runloop issue, but 
>>>> I have no idea what I can do to work around this. I've tried moving my 
>>>> -setWantsLayer: call to various places within the animation method but 
>>>> this has no effect.
>>>> 
>>>> Any help is greatly appreciated.
>>>> Thanks,
>>>> Indragie
>>>> --------
>>>> http://indragie.com _______________________________________________
>>>> 
>>>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>>>> 
>>>> 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:
>>>> http://lists.apple.com/mailman/options/cocoa-dev/joshaber%40gmail.com
>>>> 
>>>> This email sent to josha...@gmail.com
>>> 
>> 
>> _______________________________________________
>> 
>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
>> 
>> 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:
>> http://lists.apple.com/mailman/options/cocoa-dev/pierre.bernard%40lists.houdah.com
>> 
>> This email sent to pierre.bern...@lists.houdah.com
> 
> - - -
> Houdah Software s. à r. l.
> http://www.houdah.com
> 
> HoudahGeo: One-stop photo geocoding
> HoudahSpot: Powerful Spotlight frontend
> 
> 
> 
> 

_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to