Scrollview 如何在ios中一次移动两个图像

Scrollview 如何在ios中一次移动两个图像,scrollview,Scrollview,我有一组图像。当我移动一个图像时,剩余的图像也需要沿第一个图像的相同方向移动。 这是我的密码 (void)scrollViewDidScroll:(UIScrollView *)scrollView{ AppDelegate *app = (AppDelegate *)[[UIApplication sharedApplication]delegate]; float y = myScroll.contentOffset.y + recipeImageView.frame.origi

我有一组图像。当我移动一个图像时,剩余的图像也需要沿第一个图像的相同方向移动。 这是我的密码

(void)scrollViewDidScroll:(UIScrollView *)scrollView{
   AppDelegate *app = (AppDelegate *)[[UIApplication sharedApplication]delegate];
   float y = myScroll.contentOffset.y + recipeImageView.frame.origin.y;
   float x = myScroll.contentOffset.x + recipeImageView.frame.origin.x;
   NSLog(@"x Position is :%f , y position is : %f",x,y);

   for(int i=0;i<=[app phhhhh].count;i++){
      UICollectionViewCell *cell = 
         [[UICollectionViewCell alloc]initWithFrame:CGRectMake(10, 
         (self.view.frame.size.height-imageHeight)/2-50, imageWidth , 649)];
      recipeImageView = [[UIImageView alloc] initWithFrame:CGRectMake(x, y, imageWidth , 649)];

      NSIndexPath * indexPath = [_collectionView indexPathForCell:cell];
      NSLog(@"rsdf");
      recipeImageView.image = [UIImage imageNamed:[[app phhhhh] objectAtIndex:indexPath.row]];

      [cell addSubview:recipeImageView];
   }
}
(无效)scrollViewDidScroll:(UIScrollView*)scrollView{
AppDelegate*app=(AppDelegate*)[[UIApplication sharedApplication]delegate];
float y=myScroll.contentOffset.y+recipeImageView.frame.origin.y;
float x=myScroll.contentOffset.x+recipeImageView.frame.origin.x;
NSLog(@“x位置为:%f,y位置为:%f”,x,y);
对于(inti=0;i试试这个

[scrollView setContentOffset:CGPointMake(x, y) animated:YES];