UIView更流畅 [英] Smoother UIView

查看:42
本文介绍了UIView更流畅的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种方法来使我的应用程序(首先)的菜单系统更流畅地滚动.目前,我在IB中建立了一个全景图类型的视图,该视图的宽约为1900px,高为480.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 in1-2秒):

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];    
}

我已将IB中的所有内容设置为不透明,并且未为每个按钮/图像选择绘制前清除上下文".在3GS上,这看起来比3G设备更平滑,但仍然不完美-动画上仍然口吃.

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?

推荐答案

您绝对应该使用工具来调试此问题(除非有人立即获得答案).您可以轻松调试帧速率,并查看不透明/透明的图层(使用核心动画"工具中的混合图层"选项.

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).

作为最后的手段,您还可以使用图像显示按钮.创建菜单的屏幕快照",然后滑动该菜单(这只是一个项目,即UIImageView).动画制作完成后(或之前),您可以使用真正的UIView(包括按钮)快速替换UIImageView.

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.

我相信Apple在退出应用程序时也会使用此技巧(一种形式);您会看到该应用越来越小,直到消失为止.

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.

这篇关于UIView更流畅的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆