Search code examples
objective-ccocoa-touchios5uitableviewanimated

What does "animated" mean and/or used for?


I see this used a lot however I'm not sure what it does.

animated:YES

or

animated:NO

For example in a viewDidLoad method I might have this code

self.tableView.allowsSelectionDuringEditing = YES;

and in a viewWillAppear I might have this code

// some code here, and/or acondition is met, therefore put the tableview in editing mode

[self setEditing:YES animated:NO];

So again, what is animated:NO mean? And what is the difference between animated:NO and animated:YES? I do not see a visible and/or functional difference in my application.


Solution

  • iOS can animate many changes to on-screen user interface elements. For example, if you open the Settings app on an iPhone or iPod, then tap the Brightness row, the Brightness page will slide onto the screen over about .25 seconds, instead of just instantaneously replacing the main Settings page. This is an animated change to the user interface. This particular animation happens when you send the pushViewController:animated: message to a UINavigationController with the animated parameter set to YES.

    In the case of the setEditing:animated: message, you can see an example of the animated change by opening the Phone app, selecting the Recents tab, and touching the Edit button. All of the rows slide to the right, hiding the disclosure buttons and revealing the delete buttons. This change is animated over about .25 seconds because the animated parameter of the message was YES. If the animated parameter were NO, the rows would change instantaneously to show the delete buttons and not show the disclosure buttons.