Workarounds for IOS Uiimageview Direct response to click events

Source: Internet
Author: User

Uiimageview gesture handling can respond to click events.

1. self.allScreenImg.userInteractionEnabled = Yes;//uiimageview does not respond to gestures by default and needs to be turned on userinteractionenabled

Handling Click events

uitapgesturerecognizer* Singletap = [[UITapGestureRecognizer alloc] initwithtarget:self action: @selector ( Clickallscreen:)];

[Self.allscreenimg Addgesturerecognizer:singletap];


2. How to add a process

-(void) Clickallscreen: (UITapGestureRecognizer *) Recognizer {

allscreenviewcontroller* Recordviewcontroller = [[Allscreenviewcontroller alloc] initwithstoryboard];

[Self.navigationcontroller Pushviewcontroller:recordviewcontroller Animated:yes];

}


The above can be done in response to the Uiimageview click event.

Method Two:

Set tag for Uiimageview to process gestures directly to handle click events:

Imageview.settag = 333;

-(void) Touchesbegan: (Nsset *) touches withevent: (Uievent *) Event {

uiimageview* img = (Uiimageview *) [Self.view viewwithtag:333];

if (IMG) {

TODO some thing

}

}




Reference Blog: http://www.tekuba.net/program/274/


This article is from the "Sheep" blog, please make sure to keep this source http://5934497.blog.51cto.com/5924497/1633896

Workarounds for IOS Uiimageview Direct response to click events

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.