|
|
|
Zooming UIImageView in UIScrollView goes out of bounds |
|
|
|
|
|
|
|
I've successfully implemented zooming of UIImageView in my UIScrollView but I have faced with a strange problem that irritates me.
Before zooming
after zooming
code:
Code (Objective-C)
- (void)viewDidLoad {
[super viewDidLoad];
for(int ii=0; ii<[myArray count];ii++)
{
NSString *strFilePath = [myArray objectAtIndex:ii];
if (![strFilePath isEqualToString:@""]) {
NSString *proimg1 =[NSString stringWithFormat:@"%@/%@",kBaseURL,strFilePath];
[arrayOfImages addObject:proimg1];
}
}
int x = 0;
int y = 32;
int z = 0;
for (j=0; j<arrayOfImages.count;j++){
imageView = [[AsyncImageView alloc]init];
[[AsyncImageLoader sharedLoader] cancelLoadingImagesForTarget:imageView];
NSURL *url = [NSURL URLWithString:[arrayOfImages objectAtIndex:j]];
imageView.imageURL = url;
[imageView setContentMode:UIViewContentModeScaleAspectFit];
imageView.clipsToBounds = YES;
imageView.tag = 1;
self.scrollViewimg = [[UIScrollView alloc] initWithFrame:CGRectMake( self.imageScrollView.frame.size.width * z++, y,self.imageScrollView.frame.size.width,imageScrollView.frame.size.height)];
self.scrollViewimg.delegate = self;
self.scrollViewimg.minimumZoomScale = 1.0f;
self.scrollViewimg.maximumZoomScale = 2.0f;
imageView.frame = self.scrollViewimg.bounds;
[self.scrollViewimg addSubview:imageView];
[self.imageScrollView addSubview:self.scrollViewimg];
x = x + self.imageScrollView.frame.size.width;
}
[imageScrollView setContentOffset:CGPointMake((myInteger*self.imageScrollView.frame.size.width), self.imageScrollView.frame.size.height)];
imageScrollView.contentSize=CGSizeMake(x, y);
imageScrollView.pagingEnabled=TRUE;
}
- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView {
return [scrollView viewWithTag:1];
}
Tag : Mobile, iOS, iPhone, Objective-C
|
|
|
|
|
|
Date :
2015-07-28 15:04:56 |
By :
vishwa |
View :
1431 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 00
|