2010-08-13 4 views
1

어제 물어 본 질문에서 계속하십시오.pagingScrollView 내에서 확대/축소

필자는 y 축에서만 페이지하는 페이징 scrollView가 있습니다. 지금 내가 UIImageViews 다른 UIImages 및 photScroller 포함하는 배열을 가지고 내가 기대하는 것처럼 작동하지만 다른 scrollView의 subview로 pinching 및 확대/축소를 갤러리를 나누기 허용 할 때 추가하려고하면 작동합니다.

나누기로 말하자면 첫 번째 이미지 만로드되지만 나머지 이미지에는 남은 공백이 발생합니다.

 

    - (void)loadView{

// Creates 4 images from the file names UIImage *img0 = [UIImage imageNamed:@"29.png"]; UIImage *img1 = [UIImage imageNamed:@"33.png"]; UIImage *img2 = [UIImage imageNamed:@"IMAG0085.JPG"]; UIImage *img3 = [UIImage imageNamed:@"DSC00081.JPG"]; NSMutableArray *imgArray = [[NSMutableArray alloc] initWithObjects:img0,img1,img2, img3, nil]; //Places images into array CGRect pagingScrollViewFrame = [[UIScreen mainScreen] bounds]; // Creates initial scrollViewFrame to be the size of the screen pagingScrollViewFrame.origin.x -= 10; //moves it 10px to the left pagingScrollViewFrame.size.width += 20; //adds 20px to the right creating a 10px blank buffer either side pagingScrollView = [[UIScrollView alloc] initWithFrame:pagingScrollViewFrame]; //Creates the pagingScrollView with the size specified with the frame pagingScrollView.pagingEnabled = YES; //allow paging pagingScrollView.backgroundColor = [UIColor blackColor]; //background black pagingScrollView.contentSize = CGSizeMake(pagingScrollViewFrame.size.width * [imgArray count], pagingScrollViewFrame.size.height); //sets the width of the scroll view depending on the number in amges in the array. self.view = pagingScrollView; //add the pagingScrollView to the main view for (int i=0; i < [imgArray count]; i++) { //loop to add the images to an imageView and then add them to the paging ScrollView /*--------Gets the image from the array and places it in an imageView------*/ UIImageView *page = [[UIImageView alloc] initWithImage: [imgArray objectAtIndex:i]]; page.frame = [[UIScreen mainScreen] bounds]; page.contentMode = UIViewContentModeScaleAspectFit; //[page.setClipsToBounds:YES]; CGRect cgRect = [[UIScreen mainScreen] bounds]; CGSize cgSize = cgRect.size; [page setFrame:CGRectMake((i*pagingScrollViewFrame.size.width)+10, 0, cgSize.width, cgSize.height)]; /*--------Creates Zooming scrollView and adds the imageView as a subView------*/ UIScrollView *zoomingScrollView = [[UIScrollView alloc] initWithFrame:cgRect]; zoomingScrollView.delegate = self; zoomingScrollView.maximumZoomScale = 4.0; zoomingScrollView.clipsToBounds = YES; [zoomingScrollView addSubview:page]; [pagingScrollView addSubview:zoomingScrollView]; }} - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView{ NSArray *array = [scrollView subviews]; return [array lastObject]; }

답변

2
zoomingScrollView.frame = CGRectMake((i*pagingScrollViewFrame.size.width)+10, 0, cgSize.width, cgSize.height)]; 
page.frame = zoomingScrollView.bounds; 
관련 문제