私はみんな、
画像を含む NSArray があり、(iPhone フォト ライブラリのように) 左または右にパンして、ある画像から別の画像に渡すことができません。私の写真の配列は、コレクション ビューから取得されます。最初に表示される画像は、コレクション ビューで選択した画像です。
今のところ、右の画像を表示して、この画像を左右に移動することはできますが、他の画像を表示する方法がわかりません。画像が私のビューで 50% 以上になると、中央に移動します。
どうもありがとう。
これが私のコードです:
- (void)viewDidLoad
{
[super viewDidLoad];
//NSLog(@"%i", _indexPhoto);
self.photoImageView.image = [UIImage imageNamed:[_photosCollectionArray objectAtIndex:_indexPhoto]];
UIPanGestureRecognizer *recognizer;
recognizer = [[UIPanGestureRecognizer alloc]initWithTarget: self action: @selector(panGestureHandle:)];
[recognizer setMinimumNumberOfTouches:1];
[recognizer setMaximumNumberOfTouches:1];
[[self view] addGestureRecognizer:recognizer];
}
-(void) panGestureHandle:(UIPanGestureRecognizer *) sender {
NSLog(@"Pan Gesture Handling");
UIPanGestureRecognizer *pangesture = (UIPanGestureRecognizer *)sender;
CGPoint translation = [pangesture translationInView:self.view];
CGPoint imageViewPosition = _photoImageView.center;
imageViewPosition.x += translation.x;
_photoImageView.center = imageViewPosition;
[pangesture setTranslation:CGPointMake(0, 0) inView:self.view];
}