iphone – 触摸内部的UIImageView

我试图实现类似于UIButton里面的Touch Up的触摸事件。我已经看到一些使用touchesBegan的代码:withEvent,但它看起来需要我的手指滑过屏幕。我其实只是想触摸图像

码:

- (void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event {   
    NSLog(@"Image touched!");
}

问候!

您可以使用手势来触摸UIImageView。

UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc]
                         initWithTarget:self action:@selector(ClickEventOnImage:)];
        [tapRecognizer setNumberOfTouchesRequired:2];
        [tapRecognizer setDelegate:self];
        //Don't forget to set the userInteractionEnabled to YES, by default It's NO.
        myImageView.userInteractionEnabled = YES;
        [myImageView addGestureRecognizer:tapRecognizer];

实现ClickEventOnImage功能。

-(void) ClickEventOnImage:(id) sender
{

}
http://stackoverflow.com/questions/6372505/touch-up-inside-for-a-uiimageview

本站文章除注明转载外,均为本站原创或编译
转载请明显位置注明出处:iphone – 触摸内部的UIImageView