본문 바로가기

Apple - IPhone / IPod Touch/App 소개

How to Double tapping UIScrollView to bring to initial zoom scale

@interface UIView (Gestures)   // undocumented SDK extension
- (void)zoomToScale:(float)scale;
- (void)rotateToDegrees:(float)degrees;
- (void)setRotationDegrees:(float)degrees duration:(NSTimeInterval)duration;
- (float)rotationDegrees;
- (void)setZoomScale:(float)scale duration:(NSTimeInterval)duration;
- (float)zoomScale;
@end


- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
    if(type == 2) return View;
    else if(type == 1) return Panel;
    return nil;
}

- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale
{
}

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    [super touchesBegan:touches withEvent:event];
    UITouch *touch = [touches anyObject];
    if ([touch tapCount] == 2)
    {
        if(type == 1) {
            [Panel setZoomScale:1.0    duration:0.2];
        }
        else if(type == 2) {
            [View setZoomScale:1.0    duration:0.2];
        }
    }
}