How to let the pageController control the UIImageView?
I want a UIImageView swipe left, the UIImageView will change the image, at this time, the pageController +1, if swipe right, the pageContoller -1, and display the previ开发者_开发技巧ous image... ...How can I implement it? Any simple code? thz u.
Just attach a UISwipeGestureRecognizer to the UIImageView. When the gesture recognizer triggers, you would check it's direction and then change images and update the pageController accordingly.
UIGestureRecognizer *recognizer;
recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(next:)];
UISwipeGestureRecognizer *swipeLeftRecognizer = (UISwipeGestureRecognizer *)recognizer;
swipeLeftRecognizer.direction = UISwipeGestureRecognizerDirectionLeft;
[self.view addGestureRecognizer:swipeLeftRecognizer];
swipeLeftRecognizer=nil;
[recognizer release];
recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(prev:)];
UISwipeGestureRecognizer *swipeRightRecognizer = (UISwipeGestureRecognizer *)recognizer;
swipeRightRecognizer.direction = UISwipeGestureRecognizerDirectionRight;
[self.view addGestureRecognizer:swipeRightRecognizer];
swipeLeftRecognizer=nil;
[recognizer release];
精彩评论