2010-05-01 1 views
0

В этом проблема ... Я использую CA Tiled Layer для отображения большого jpg. Вид загружается нормально, и когда я иду, чтобы прокручивать, он отлично работает. Однако, как только я приближать или один раз, она прокручивается в верхнем левом углу (до узловой точки) и не будет прокручиваться на всех. Масштабирование работает отлично, но я просто не могу прокручивать.iPhone: CATiledLayer/UIScrollView не прокручивается после масштабирования и только увеличивает масштаб до точки привязки

Вот мой код:

#import <QuartzCore/QuartzCore.h> 
#import "PracticeViewController.h" 

@implementation practiceViewController 
//@synthesize image; 

- (void)viewDidLoad 
{ 


    NSString *path = [[NSBundle mainBundle] pathForResource:@"H-5" ofType:@"jpg"]; 
    NSData *data = [NSData dataWithContentsOfFile:path]; 
    image = [UIImage imageWithData:data]; 

    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.tileSize = CGSizeMake(1000, 1000); 
    tiledLayer.levelsOfDetail = 6; 
    tiledLayer.levelsOfDetailBias = 0; 
    tiledLayer.bounds = pageRect; 
    tiledLayer.transform = CATransform3DMakeScale(1.0f, -1.0f, 0.3f); 

    myContentView = [[UIView alloc] initWithFrame:self.view.bounds]; 
    [myContentView.layer addSublayer:tiledLayer]; 

    UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds]; 
    scrollView.delegate = self; 
    scrollView.contentSize = pageRect.size; 
    scrollView.minimumZoomScale = .2; 
    scrollView.maximumZoomScale = 1; 
    [scrollView addSubview:myContentView]; 
    [self.view addSubview:scrollView]; 


} 

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView 
{ 
    return myContentView; 
} 

- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx 
{ 
    NSString *path = [[NSBundle mainBundle] pathForResource:@"H-5" ofType:@"jpg"]; 
    NSData *data = [NSData dataWithContentsOfFile:path]; 
    image = [UIImage imageWithData:data]; 

    CGRect imageRect = CGRectMake (0.0, 0.0, image.size.width, image.size.height); 
    CGContextDrawImage (ctx, imageRect, [image CGImage]); 
} 

@end 
+0

возможно дубликат http://stackoverflow.com/questions/2738412/why-wont-my-catiledlayer-scroll-in -a-uiscrollview-after-zoomoming –

+0

другой поток начался с другой проблемы (которая была решена) и превратилась в эту конкретную проблему, которая еще не решена. – Brodie

+0

дубликат ниже связанного вопроса http://stackoverflow.com/questions/2738412/why-wont-my-catiledlayer-scroll-in-a-uiscrollview-after-zooming –

ответ

0

Смотрите выше перечисленное вопрос

Смежные вопросы