【问题标题】:IBOutletCollection and UITapGestureIBOutletCollection 和 UITapGesture
【发布时间】:2013-09-24 22:08:26
【问题描述】:

我正在尝试将UILongPressGestureRecognizerUITapGestureRecognizer 添加到UIImageViewsIBOutletCollection,但它不起作用。这是我正在使用的代码:

UILongPressGestureRecognizer *pressRecognizer = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(deleteImage:)];
UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(selectImage:)];

pressRecognizer.delegate = self;
tapRecognizer.delegate = self;

for (UIImageView *imageView in myImageViewCollection)
{
    [imageView addGestureRecognizer:pressRecognizer];
    [imageView addGestureRecognizer:tapRecognizer];

    imageView.userInteractionEnabled = YES;
}

- (void)selectImage:(UITapGestureRecognizer *)sender
{
    NSLog(@"Select");
}

- (void)deleteImage:(UILongPressGestureRecognizer *)sender
{
    NSLog(@"Delete");
}

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
    return YES;
}

我已遵守UIGestureRecognizerDelegate。我做错了什么?

【问题讨论】:

    标签: ios objective-c uitapgesturerecognizer iboutletcollection


    【解决方案1】:

    请参阅this question。听起来是同一个问题。我重新创建了您的问题,手势识别器仅绑定到最后一个视图。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多