2010.07.12 // 이 글은 망했습니다. http://myriky.net/tc/124 를 참고하세요~ ------------------------------- 어떤 외국인 아저씨가 //
// ScrollView.h // ScrollView // // Created by Riky.G Kim on 09. 04. 22. // Copyright 2009 TSMobile. All rights reserved. // #import <UIKit/UIKit.h>
@interface ScrollView : UIScrollView <UIScrollViewDelegate> {
UIImageView *SubImage; float ZoomValue; } @end
// // ScrollView.m // ScrollView // // Created by Riky.G Kim on 09. 04. 22. // Copyright 2009 TSMobile. All rights reserved. // #import "ScrollView.h"
@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 @implementation ScrollView
- (id)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { self.delegate = self; self.alwaysBounceHorizontal = YES; self.alwaysBounceVertical = YES; self.bounces = YES; self.bouncesZoom = YES; SubImage = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"missingtaiji.jpg"]] autorelease]; ZoomValue = 100; CGSize ImageSize = SubImage.image.size; //minumum zoomscale of image while(ImageSize.width*(ZoomValue-1)/100>=320||ImageSize.height*(ZoomValue-1)/100>=460){ ZoomValue--; } [self setContentSize:ImageSize]; [self setMinimumZoomScale:ZoomValue/100]; [self addSubview:SubImage]; } return self; } - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView { return SubImage; } - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; if ([touch tapCount] == 2) { [SubImage setZoomScale:1.0 duration:0.0]; [self setContentOffset:CGPointMake([touch locationInView:self].x*ZoomValue/100,[touch locationInView:self].y*ZoomValue/100)]; } [super touchesBegan:touches withEvent:event]; } @end 도움이 되길 바라며~ |

ScrollView.zip



댓글을 달아 주세요
FF 에서는 코드가 안보임ㅡㅡ
좋은 소스코드 갑사합니다. 복받으세요.
오류발견 ㅋㅋ