0

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

(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];
   }
}
4

1 回答 1

0

尝试这个

[scrollView setContentOffset:CGPointMake(x, y) animated:YES];
于 2014-07-22T18:21:45.130 回答