Thursday, March 24, 2011

set default zoom level in UIScrollview

- (void)viewDidLoad {

imageView= [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"KK_Map-02.jpg"]];
//self.imageView = imageView;
//[tempImageView release];

[super viewDidLoad];
//aWw.delegate = self;
//[scrollView setUserInteractionEnabled:YES];
scrollView.contentSize = CGSizeMake(imageView.frame.size.width, imageView.frame.size.height);//imageView.frame.size.width*9.6, imageView.frame.size.height*0.9

//scrollView.contentOffset = CGPointMake(imageView.frame.size.width/4,
// imageView.frame.size.height/4);


//CGRect rect = CGRectMake(119, 42, 208, 166);

scrollView.maximumZoomScale = 4.0;
scrollView.minimumZoomScale = 0.33;
scrollView.clipsToBounds = YES;
scrollView.delegate = self;
scrollView.bouncesZoom=FALSE;




[scrollView addSubview:imageView];


float minimumScale = [scrollView frame].size.width / [imageView frame].size.width;
[scrollView setMinimumZoomScale:minimumScale];
[scrollView setZoomScale:minimumScale];

}

No comments:

FEEDJIT Live