0

I have a NSView in my project that I want to move but the animation I usually use for other objects doesn't work with it... what should I do to make it move? Here is my code:

[[NSAnimationContext currentContext] setDuration:1.0];
NSRect rect = NSMakeRect(59.0,10.0,682.0,575.0);
[[self.myView animator] setFrame: rect];
Peter Hosey
  • 95,783
  • 15
  • 211
  • 370
Blue
  • 2,300
  • 3
  • 21
  • 32
  • Well, what happens instead? (And have you verified that `self.myView` is not `nil`, and that the frame you've hard-coded there is different from its existing frame?) – Peter Hosey Jun 10 '13 at 23:03
  • Instead of the animation nothing happens... but I tryed to execute that code alone and yes it works... it doesn't work when I call it after I executed an IAP... and now I noticed that sometimes I get a warning in the Log panel: "CoreAnimation: warning, deleted thread with uncommitted CATransaction; set CA_DEBUG_TRANSACTIONS=1 in environment to log backtraces."... I have no idea what this can mean... – Blue Jun 11 '13 at 10:34
  • What do you mean by “after I executed an IAP”? What method did you have this code in? – Peter Hosey Jun 11 '13 at 14:59
  • I call it from inside: - (void)paymentQueue:(SKPaymentQueue *)queue updatedTransactions:(NSArray *)transactions – Blue Jun 11 '13 at 15:17
  • From the CA log message (assuming that it's actually relevant and not indicative of another, unrelated problem), it sounds like that method is called on another thread, and that thread ends shortly after you return from that method. Starting the animation(s) on the main thread instead is the correct solution in that case. – Peter Hosey Jun 11 '13 at 15:26
  • Yes, that must be why with performSelectorOnMainThread it is working fine and I don't get that message anymore... Thanks for your help bro – Blue Jun 11 '13 at 15:53

1 Answers1

1

I found the way to make it work... For some reason the animation was working if called alone but not working when called after an IAP... I found out that calling the void with the animation with this line of code made it work:

[self performSelectorOnMainThread:@selector(myAnimation) withObject:nil waitUntilDone:NO];
Blue
  • 2,300
  • 3
  • 21
  • 32