我对 iOS 开发还很陌生,所以我的问题是:如果我有 2 张图像我想同时用手势引导它们,那么它们实际上是同时朝着同一个方向移动,这可能吗?
问问题
143 次
2 回答
0
您需要获取被触摸的图像位置与将被移动到的位置(触摸位置)之间的差异。例如,图像位于 {25, 50} 并将移动到 {30, 55},差异为 {5, 5}。现在您知道可以通过添加相同的差异来修改其他图像。
于 2013-09-14T14:46:28.820 回答
0
这是我目前的代码
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);
UICollectionViewCell *cell=[[UICollectionViewCell alloc]initWithFrame:CGRectMake(10, (self.view.frame.size.height-imageHeight)/2-50, imageWidth , 649)];
NSIndexPath * indexPath = [_collectionView indexPathForCell:cell];
recipeImageView = [[UIImageView alloc] initWithFrame:CGRectMake(x, y, imageWidth , 649)];
recipeImageView.image = [UIImage imageNamed:[[app phhhhh] objectAtIndex:indexPath.row]]; recipeImageView.multipleTouchEnabled = YES;recipeImageView.userInteractionEnabled = YES;
[cell addSubview:recipeImageView];
于 2013-09-17T10:33:13.663 回答