0

I was studying about begin animation with UIView, usually in most tutorials they always use the same syntax:

[UIView beginAnimations:nil context:NULL];

I see in the code that inside the beginAnimation we can put a nsstring, and in context a void function, right? For that I do this:

[UIView beginAnimations:@"Will Start" context:@selector(start)];

-(void)start{

NSLog(@"Animation Running");

}

But the nsstring 'will start' was not showing to me, and the void function 'start' don't called. I do not know if I'm doing it in the wrong way, but what do those options BeginAnimation of NSString type and the type context of type void? Could someone give me an example?

user3781174
  • 245
  • 5
  • 16
  • You shouldn't even be using that method. You must be looking at some pretty old tutorials. From Apple's docs for beginAnimations: "Use of this method is discouraged in iOS 4.0 and later. You should use the block-based animation methods to specify your animations instead." – rdelmar Dec 19 '14 at 23:59

1 Answers1

0

It looks like you don't quite understand how the beginAnimations:context: method works. First of all, animationId is an NSString that just identifies the animations. Second, the data you pass to context is really just any data you want. A function pointer, an object, etc.

So what you do after calling [UIView beginAnimations:context:] is send the different setAnimation messages to set properties, change the view values to the values (position, color, alpha) you ultimately want to get to, and finally send the [UIView commitAnimations] message.

A good tutorial that explains this in more detail is here.

Jadar
  • 1,643
  • 1
  • 13
  • 25