Reputation:
i'm looking for a way to make the menu system of my (very first) app scroll more smoothly. Currently I've got a panorma type view built in IB that's ~1900px wide by 480 tall image. On top of this are 8 buttons in various places along the view/image, when one of the buttons is selected i update 'xPoint' and call the below to update what's on screen (between 400-600px movement each time a button gets clicked in 1-2 seconds duration):
-(void)moveView:(NSNumber *)duration{ [UIView beginAnimations:nil context:NULL];{ [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; [UIView setAnimationDuration:[duration floatValue]]; [UIView setAnimationDelegate:self]; viewRect = self.view.frame; viewRect.origin.x = xPoint; self.view.frame = viewRect; } [UIView commitAnimations]; }
I've set everything in IB to be opaque and have unselected 'Clear context before drawing' for every button/image. On a 3GS this seems smoother than a 3G device but still non-perfect - still getting stuttering on the animation.
Is there a better way to do this? If not is there any way i can optimize/smooth out the movement animation?
Upvotes: 0
Views: 572
Reputation: 3973
You should definitely use instruments to debug this issue (unless somebody has the answer right away). you can easily debug framerate + see what layers are opaque/transparent (with the 'blended layers' option in the Core Animation instrument..
Also, at the same time, measure other device activity (that might be the problem).
As a very last resort, you could also use an image to display the buttons. Create a 'screenshot' of the menu, and make THAT slide (that's only one item, a UIImageView). After (or just before) your animation is done, you could quickly replace the UIImageView with the real UIView, including the buttons.
I believe Apple also uses (a form) of this trick when quitting the app; you see the app become smaller and smaller until it disappears.
Upvotes: 1