У меня есть UIScrollView, поддерживаемый CATiledLayer. Слой вытягивает плитки с сервера и отображает их в ответ на то, что запрашивается при вызове drawLayer:inContext
. Вот как это выглядит:.Почему не масштабируется изображение ScrollView/CATiledView?
-(void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx{
ASIHTTPRequest *mapRequest;
WMSServer *root = self.mapLayer.parentServer;
while(root == nil){
root = self.mapLayer.parentLayer.parentServer;
}
//Get where we're drawing
CGRect clipBox = CGContextGetClipBoundingBox(ctx);
double minX = CGRectGetMaxY(clipBox);
double minY = CGRectGetMinX(clipBox);
double maxX = CGRectGetMinY(clipBox);
double maxY = CGRectGetMaxX(clipBox);
//URL for the request made here using the min/max values from above
NSURL *url = [[NSURL alloc] initWithString:path];
mapRequest = [ASIHTTPRequest requestWithURL:url];
[url release];
[mapRequest startSynchronous];
//Wait for it to come back...
//Turn the Data into an image
NSData *response = [mapRequest responseData];
//Create the entire image
CGDataProviderRef dataProvider = CGDataProviderCreateWithCFData((CFDataRef)response);
CGImageRef image = CGImageCreateWithPNGDataProvider(dataProvider, NULL, true, kCGRenderingIntentDefault);
CGDataProviderRelease(dataProvider);
//Now paint the PNG on the context
CGContextDrawImage(ctx, clipBox, image);
}
Проблема возникает, когда я увеличить размер плиток (как указано в clipBox
прямоугольника) сжимается вниз, а если в скажем, 32 по 32 пикселей, URL правильно сформирован для 32 пикселей, но то, что отображается на экране, масштабируется до значения по умолчанию tileSize (в этом случае 128 на 128 пикселей). Есть ли способ, которым я могу заставить слой правильно рисовать эти изображения.