【发布时间】:2013-11-06 07:06:26
【问题描述】:
我有一个 ImageView 和数组中的图像 URL。我想在 UIImageView 上下载并显示这些图像,但是发出这个我在该视图上面临两个手势的问题,因此仅在 ImageView 上的内部手势不希望工作。
我的代码如下所示
[self.imageView setUserInteractionEnabled:YES];
UISwipeGestureRecognizer *swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipe:)];
UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipe:)];
// Setting the swipe direction.
[swipeLeft setDirection:UISwipeGestureRecognizerDirectionLeft];
[swipeRight setDirection:UISwipeGestureRecognizerDirectionRight];
// Adding the swipe gesture on image view
[self.imageView addGestureRecognizer:swipeLeft];
[self.imageView addGestureRecognizer:swipeRight];
- (void)handleSwipe:(UISwipeGestureRecognizer *)swipe {
if (swipe.direction == UISwipeGestureRecognizerDirectionLeft) {
NSLog(@"Left Swipe");
}
if (swipe.direction == UISwipeGestureRecognizerDirectionRight) {
NSLog(@"Right Swipe");
}
}
handleSwipe 方法没有被调用,当我移动它时也会打开侧边菜单,因为手势应用与在其 iOS 应用中打开的 facebook 侧边菜单相同。
当整个父视图也使用 Gesture 时,如何更改 ImageView 中的图像。
谢谢
【问题讨论】:
标签: ios objective-c uiimageview uigesturerecognizer