I have been looking for a way to improve the performance of my CATiledView. The view takes up nearly the entire screen (i have an iPad and iPhone version).Currently it takes about 12 seconds for the tiles to fill in completely (12 seconds on both devices). I have seen other apps use CATiledView and it take much less time for the tiles to fill.
The image I have been using is 1 7000x5000 JPEG. I have tried reducing the image doen to 5500px across and there is no change in the load time so that leads me to believe it is a problem with my code which is as follows:
update: I tried reducing the size of the images (by more than half) and there is no difference that I can tell.
-(void) loadMap{
...
UIImage *tempImage = [UIImage imageWithData:data];
self.image = tempImage;
CGRect pageRect = CGRectMake(0, 0, image.size.width, image.size.height);
CATiledLayer *tiledLayer = [CATiledLayer layer];
tiledLayer.anchorPoint = CGPointMake(0.0f, 1.0f);
tiledLayer.delegate = self;
tiledLayer.levelsOfDetail = 6;
tiledLayer.levelsOfDetailBias = 0;
tiledLayer.bounds = pageRect;
tiledLayer.transform = CATransform3DMakeScale(1.0f, -1.0f, 0.3f);
CGRect imageRect = CGRectMake(0, 0, image.size.width, image.size.height);
myContentView = [[UIView alloc] initWithFrame:imageRect];
[myContentView.layer addSublayer:tiledLayer];
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:self.chartView.frame];
scrollView.delegate = self;
scrollView.contentSize = pageRect.size;
scrollView.minimumZoomScale = .2;
scrollView.maximumZoomScale = 1;
scrollView.clipsToBounds = YES;
[scrollView addSubview:myContentView];
[self.chartView addSubview:scrollView];
scrollView.zoomScale = .2;
}
- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx
{
CGRect imageRect = CGRectMake (0.0, 0.0, image.size.width, image.size.height);
CGContextDrawImage (ctx, imageRect, [image CGImage]);
}