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

时间:2013-09-17 10:58:27

标签: scrollview

我有一系列图像。当我移动一个图像时,剩余图像也需要在第一个图像的相同方向上移动。 这是我的代码。

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

1 个答案:

答案 0 :(得分:0)

试试这个

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