我有一系列图像。当我移动一个图像时,剩余图像也需要在第一个图像的相同方向上移动。 这是我的代码。
(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];
}
}
答案 0 :(得分:0)
试试这个
[scrollView setContentOffset:CGPointMake(x, y) animated:YES];