在我的应用程序中,我一直在尝试在iPhone 5上滚动表格 View 时在核心动画工具中使fps高于60。 (通过注释掉事物或删除 Nib 中的 View )。
几个小时后,我终于感到好奇,并启动了一个全新的垃圾应用程序,只不过是一个UITableViewController,它只是一遍又一遍地吐出相同的单元格。滚动时我将其分析为1000行,而STILL仅达到了50的高位。
我在这里想念什么?没有办法是正确的。没有比这个简单的表格更简单的显示了:
我上传了准系统应用here。
有人可以确认我没有疯吗?
更新
60fps是您可以在iPhone上获得的最大速度吗?核心动画会比以前更快吗?
最佳答案
有两个想法:
fpsLabel
放在屏幕上的备用位置,该位置每秒用CADisplayLink
更新一次(或者,如果您有自定义绘制例程,则可以在其中进行自己的fps计算):@interface ViewController () <UITableViewDataSource>
@property (nonatomic) CFTimeInterval previousTimestamp;
@property (nonatomic) NSInteger frameCount;
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.previousTimestamp = CFAbsoluteTimeGetCurrent();
CADisplayLink *displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(handleDisplayLink:)];
[displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSRunLoopCommonModes];
}
- (void)handleDisplayLink:(CADisplayLink *)displayLink;
{
CFTimeInterval now = CFAbsoluteTimeGetCurrent();
CFTimeInterval elapsed = now - self.previousTimestamp;
self.frameCount++;
if (elapsed > 1.0)
{
CGFloat fps = self.frameCount / elapsed;
dispatch_async(dispatch_get_main_queue(), ^{
self.fpsLabel.text = [NSString stringWithFormat:@"%.1f fps", fps];
});
self.previousTimestamp = now;
self.frameCount = 0;
}
}
最重要的是,在发行版本条件(即未链接到计算机,正在运行非调试版本)中结合了更准确的度量(通过代码),我认为您会发现iPhone 5上的表格 View 性能非常出色,锁定为60 fps。但是,即使您的UI下降到50s帧/秒左右,我个人仍然认为还可以。
关于iphone - 为什么即使在完全裸露的UITableView滚动屏幕上,我的iPhone 5也不显示60+ fps?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14867555/