Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/36.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/27.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 在pagingScrollView中缩放_Iphone_Objective C - Fatal编程技术网

Iphone 在pagingScrollView中缩放

Iphone 在pagingScrollView中缩放,iphone,objective-c,Iphone,Objective C,我昨天问的问题的后续问题 我有一个页面滚动视图,它只显示y轴上的页面。目前我有一个UIImageView数组,其中包含不同的UIImages,photoScroller可以像我预期的那样工作,但是当我尝试将imageView添加为另一个scrollView的子视图以允许收缩和缩放时,它会破坏图库 我所说的中断是指它只加载第一个图像,但为其他图像保留空间,不会发生挤压 -(void)负荷视图{ //从文件名创建4个图像 UIImage*img0=[UIImage ImageName:@“29.

我昨天问的问题的后续问题

我有一个页面滚动视图,它只显示y轴上的页面。目前我有一个UIImageView数组,其中包含不同的UIImages,photoScroller可以像我预期的那样工作,但是当我尝试将imageView添加为另一个scrollView的子视图以允许收缩和缩放时,它会破坏图库

我所说的中断是指它只加载第一个图像,但为其他图像保留空间,不会发生挤压


-(void)负荷视图{

//从文件名创建4个图像 UIImage*img0=[UIImage ImageName:@“29.png”]; UIImage*img1=[UIImage ImageName:@“33.png”]; UIImage*img2=[UIImage ImageName:@“IMAG0085.JPG”]; UIImage*img3=[UIImage ImageName:@“dsc0081.JPG”]; NSMUTABLEARRY*imgArray=[[NSMUTABLEARRY alloc]initWithObjects:img0、img1、img2、img3、nil];//将图像放入数组中 CGRect pagingScrollViewFrame=[[UIScreen mainScreen]bounds];//创建初始scrollViewFrame作为屏幕大小 pagingScrollViewFrame.origin.x-=10;//将其向左移动10px pagingScrollViewFrame.size.width+=20;//将20px添加到右侧,在任一侧创建一个10px的空白缓冲区 pagingScrollView=[[UIScrollView alloc]initWithFrame:pagingScrollViewFrame];//使用框架指定的大小创建pagingScrollView pagingScrollView.PaginEnabled=YES;//允许分页 pagingScrollView.backgroundColor=[UIColor blackColor];//背景黑色 pagingScrollView.contentSize=CGSizeMake(pagingScrollViewFrame.size.width*[imgArray count],pagingScrollViewFrame.size.height);//根据数组中的数字(单位:安培)设置滚动视图的宽度。 self.view=pagingScrollView;//将pagingScrollView添加到主视图 for(int i=0;i<[imgaray count];i++){//循环将图像添加到imageView,然后将其添加到分页滚动视图 /*--------从数组中获取图像并将其放置在imageView中------*/ UIImageView*页面=[[UIImageView alloc]initWithImage:[imgArray objectAtIndex:i]]; page.frame=[[UIScreen mainScreen]边界]; page.contentMode=ui视图contentmodescaleaspectfit; //[page.setclipstobunds:YES]; CGRect CGRect=[[UIScreen mainScreen]边界]; CGSize CGSize=cgRect.size; [page setFrame:CGRectMake((i*pagingScrollViewFrame.size.width)+10,0,cgSize.width,cgSize.height)]; /*--------创建缩放滚动视图并将imageView添加为子视图------*/ UIScrollView*zoomingScrollView=[[UIScrollView alloc]initWithFrame:cgRect]; zoomingScrollView.delegate=self; zoomingScrollView.maximumZoomScale=4.0; zoomingScrollView.clipsToBounds=是; [缩放滚动视图添加子视图:页面]; [分页滚动视图添加子视图:缩放滚动视图]; }} -(UIView*)视图用于缩放CrollView:(UICrollView*)滚动视图{ NSArray*数组=[scrollView子视图]; 返回[array lastObject]; }

     - (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]; }
zoomingScrollView.frame = CGRectMake((i*pagingScrollViewFrame.size.width)+10, 0, cgSize.width, cgSize.height)];
page.frame = zoomingScrollView.bounds;