{"id":82,"date":"2012-07-04T11:05:50","date_gmt":"2012-07-04T11:05:50","guid":{"rendered":"https:\/\/www.securekloud.com\/blog\/?p=82"},"modified":"2023-03-24T10:33:27","modified_gmt":"2023-03-24T10:33:27","slug":"uigesturerecognizer-for-ios","status":"publish","type":"post","link":"https:\/\/www.securekloud.com\/blog\/uigesturerecognizer-for-ios\/","title":{"rendered":"UIGestureRecognizer for IOS: How Does it Work?"},"content":{"rendered":"<p><strong>Introductions:<\/strong><\/p>\n<p>UIGestureRecognizer is an abstract base class for concrete gesture-recognizer classes.<\/p>\n<p>If you need to detect gestures in your app, such as taps, pinches, pans, or rotations, it\u2019s extremely easy with the built-in UIGestureRecognizer classes.<\/p>\n<p>In the old days before UIGestureRecognizers, if you wanted to detect a gesture such as a swipe, you\u2019d have to register for notifications on every touch within a UIView \u2013 such as touchesBegan, touchesMoves, and touchesEnded.<\/p>\n<p>The concrete subclasses of UIGestureRecognizer are the following:<\/p>\n<p><code style=\"background-color: #eee; border: 1px solid #999; display: block; padding: 20px; width: 280px;\"><br \/>\nUITapGestureRecognizer<br \/>\nUIPinchGestureRecognizer<br \/>\nUIRotationGestureRecognizer<br \/>\nUISwipeGestureRecognizer<br \/>\nUIPanGestureRecognizer<br \/>\nUILongPressGestunizer<br \/>\n<\/code><br \/>\nA gesture recognizer has one or more target-action pairs associated with it. If there are multiple target-action pairs, they are discrete, and not cumulative. Recognition of a gesture results in the dispatch of an action message to a target for each of those pairs. The action methods invoked must conform to one of the following signatures:<\/p>\n<p><code style=\"background-color: #eee; border: 1px solid #999; display: block; padding: 20px; width: 517px;\"><br \/>\n-(void)handleGesture;<br \/>\n-(void)handleGesture:(UIGestureRecognizer *)gestureRecognize;<br \/>\n<\/code><\/p>\n<p><b>Solution :<\/b><\/p>\n<p><b>Step 1 :<\/b> Create a new file of class ViewController and a UIView<\/p>\n<p><b>Step 2 :<\/b> in viewDidLoad implement concrete subclasses of UIGestureRecognizer<\/p>\n<p>eg :<\/p>\n<p><code style=\"background-color: #eee; border: 1px solid #999; display: block; padding: 20px;\"><br \/>\nUITapGestureRecognizer<br \/>\n-(void) viewDidLoad {<br \/>\nUITapGestureRecognizer * recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];<br \/>\nrecognizer.delegate = self;<br \/>\n[view addGestureRecognizer:recognizer];<br \/>\n}<br \/>\n<\/code><\/p>\n<p><b>Step 3 :<\/b> Implement the gesture handle<\/p>\n<p><code style=\"background-color: #eee; border: 1px solid #999; display: block; padding: 20px; width: 500px;\"><br \/>\n- (void)handleTap:(UITapGestureRecognizer *)recognizer {<br \/>\nNSLog (@\u201dyour implementation here\u201d);<br \/>\n}<br \/>\n<\/code><\/p>\n<p><strong>Conclusion<\/strong> :<\/p>\n<p>UIGestureRecognizer classes! These provide a default implementation of detecting common gestures such as taps, pinches, rotations, swipes, pans, and long presses. By using them, not only it reduce you code length, but it easy too.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introductions: UIGestureRecognizer is an abstract base class for concrete gesture-recognizer classes. If you need to detect gestures in your app, such as taps, pinches, pans, or rotations, it\u2019s extremely easy with the built-in UIGestureRecognizer classes. In the old days before UIGestureRecognizers, if you wanted to detect a gesture such as a swipe, you\u2019d have to [&hellip;]<\/p>\n","protected":false},"author":5,"featured_media":83,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"content-type":"","footnotes":""},"categories":[330],"tags":[],"class_list":["post-82","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-application-development"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>UIGestureRecognizer for IOS: How Does it Work? | SecureKloud<\/title>\n<meta name=\"description\" content=\"Get to know what UIGestureRecognizer is all about, its implementation, and how it provides a default implementation of detecting common gestures.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.securekloud.com\/blog\/uigesturerecognizer-for-ios\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"UIGestureRecognizer for IOS: How Does it Work? | SecureKloud\" \/>\n<meta property=\"og:description\" content=\"Get to know what UIGestureRecognizer is all about, its implementation, and how it provides a default implementation of detecting common gestures.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.securekloud.com\/blog\/uigesturerecognizer-for-ios\/\" \/>\n<meta property=\"og:site_name\" content=\"SecureKloud\" \/>\n<meta property=\"article:published_time\" content=\"2012-07-04T11:05:50+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-03-24T10:33:27+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.securekloud.com\/blog\/wp-content\/uploads\/2021\/04\/UI-Gesture-Recognizer.png\" \/>\n\t<meta property=\"og:image:width\" content=\"800\" \/>\n\t<meta property=\"og:image:height\" content=\"400\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Joe Arputhan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Joe Arputhan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.securekloud.com\/blog\/uigesturerecognizer-for-ios\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.securekloud.com\/blog\/uigesturerecognizer-for-ios\/\"},\"author\":{\"name\":\"Joe Arputhan\",\"@id\":\"https:\/\/www.securekloud.com\/blog\/#\/schema\/person\/de22247532aa8172abce3df9a1b12708\"},\"headline\":\"UIGestureRecognizer for IOS: How Does it Work?\",\"datePublished\":\"2012-07-04T11:05:50+00:00\",\"dateModified\":\"2023-03-24T10:33:27+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.securekloud.com\/blog\/uigesturerecognizer-for-ios\/\"},\"wordCount\":205,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.securekloud.com\/blog\/#organization\"},\"articleSection\":[\"Application Development\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.securekloud.com\/blog\/uigesturerecognizer-for-ios\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.securekloud.com\/blog\/uigesturerecognizer-for-ios\/\",\"url\":\"https:\/\/www.securekloud.com\/blog\/uigesturerecognizer-for-ios\/\",\"name\":\"UIGestureRecognizer for IOS: How Does it Work? | SecureKloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.securekloud.com\/blog\/#website\"},\"datePublished\":\"2012-07-04T11:05:50+00:00\",\"dateModified\":\"2023-03-24T10:33:27+00:00\",\"description\":\"Get to know what UIGestureRecognizer is all about, its implementation, and how it provides a default implementation of detecting common gestures.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.securekloud.com\/blog\/uigesturerecognizer-for-ios\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.securekloud.com\/blog\/uigesturerecognizer-for-ios\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.securekloud.com\/blog\/uigesturerecognizer-for-ios\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.securekloud.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"UIGestureRecognizer for IOS: How Does it Work?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.securekloud.com\/blog\/#website\",\"url\":\"https:\/\/www.securekloud.com\/blog\/\",\"name\":\"SecureKloud\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/www.securekloud.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.securekloud.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.securekloud.com\/blog\/#organization\",\"name\":\"SecureKloud\",\"url\":\"https:\/\/www.securekloud.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.securekloud.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.securekloud.com\/blog\/wp-content\/uploads\/2023\/03\/header-logo.png\",\"contentUrl\":\"https:\/\/www.securekloud.com\/blog\/wp-content\/uploads\/2023\/03\/header-logo.png\",\"width\":240,\"height\":48,\"caption\":\"SecureKloud\"},\"image\":{\"@id\":\"https:\/\/www.securekloud.com\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.securekloud.com\/blog\/#\/schema\/person\/de22247532aa8172abce3df9a1b12708\",\"name\":\"Joe Arputhan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.securekloud.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/www.securekloud.com\/blog\/wp-content\/uploads\/2023\/04\/joe-arputhan-150x150.jpg\",\"contentUrl\":\"https:\/\/www.securekloud.com\/blog\/wp-content\/uploads\/2023\/04\/joe-arputhan-150x150.jpg\",\"caption\":\"Joe Arputhan\"},\"description\":\"Writer, researcher, content marketing evangelist, cloud and blockchain enthusiast.\",\"sameAs\":[\"https:\/\/www.linkedin.com\/in\/joe-arputhan-68b90523\/\"],\"url\":\"https:\/\/www.securekloud.com\/blog\/author\/joe-arputhan\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"UIGestureRecognizer for IOS: How Does it Work? | SecureKloud","description":"Get to know what UIGestureRecognizer is all about, its implementation, and how it provides a default implementation of detecting common gestures.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.securekloud.com\/blog\/uigesturerecognizer-for-ios\/","og_locale":"en_US","og_type":"article","og_title":"UIGestureRecognizer for IOS: How Does it Work? | SecureKloud","og_description":"Get to know what UIGestureRecognizer is all about, its implementation, and how it provides a default implementation of detecting common gestures.","og_url":"https:\/\/www.securekloud.com\/blog\/uigesturerecognizer-for-ios\/","og_site_name":"SecureKloud","article_published_time":"2012-07-04T11:05:50+00:00","article_modified_time":"2023-03-24T10:33:27+00:00","og_image":[{"width":800,"height":400,"url":"https:\/\/www.securekloud.com\/blog\/wp-content\/uploads\/2021\/04\/UI-Gesture-Recognizer.png","type":"image\/png"}],"author":"Joe Arputhan","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Joe Arputhan","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.securekloud.com\/blog\/uigesturerecognizer-for-ios\/#article","isPartOf":{"@id":"https:\/\/www.securekloud.com\/blog\/uigesturerecognizer-for-ios\/"},"author":{"name":"Joe Arputhan","@id":"https:\/\/www.securekloud.com\/blog\/#\/schema\/person\/de22247532aa8172abce3df9a1b12708"},"headline":"UIGestureRecognizer for IOS: How Does it Work?","datePublished":"2012-07-04T11:05:50+00:00","dateModified":"2023-03-24T10:33:27+00:00","mainEntityOfPage":{"@id":"https:\/\/www.securekloud.com\/blog\/uigesturerecognizer-for-ios\/"},"wordCount":205,"commentCount":0,"publisher":{"@id":"https:\/\/www.securekloud.com\/blog\/#organization"},"articleSection":["Application Development"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.securekloud.com\/blog\/uigesturerecognizer-for-ios\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.securekloud.com\/blog\/uigesturerecognizer-for-ios\/","url":"https:\/\/www.securekloud.com\/blog\/uigesturerecognizer-for-ios\/","name":"UIGestureRecognizer for IOS: How Does it Work? | SecureKloud","isPartOf":{"@id":"https:\/\/www.securekloud.com\/blog\/#website"},"datePublished":"2012-07-04T11:05:50+00:00","dateModified":"2023-03-24T10:33:27+00:00","description":"Get to know what UIGestureRecognizer is all about, its implementation, and how it provides a default implementation of detecting common gestures.","breadcrumb":{"@id":"https:\/\/www.securekloud.com\/blog\/uigesturerecognizer-for-ios\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.securekloud.com\/blog\/uigesturerecognizer-for-ios\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.securekloud.com\/blog\/uigesturerecognizer-for-ios\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.securekloud.com\/blog\/"},{"@type":"ListItem","position":2,"name":"UIGestureRecognizer for IOS: How Does it Work?"}]},{"@type":"WebSite","@id":"https:\/\/www.securekloud.com\/blog\/#website","url":"https:\/\/www.securekloud.com\/blog\/","name":"SecureKloud","description":"","publisher":{"@id":"https:\/\/www.securekloud.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.securekloud.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.securekloud.com\/blog\/#organization","name":"SecureKloud","url":"https:\/\/www.securekloud.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.securekloud.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.securekloud.com\/blog\/wp-content\/uploads\/2023\/03\/header-logo.png","contentUrl":"https:\/\/www.securekloud.com\/blog\/wp-content\/uploads\/2023\/03\/header-logo.png","width":240,"height":48,"caption":"SecureKloud"},"image":{"@id":"https:\/\/www.securekloud.com\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.securekloud.com\/blog\/#\/schema\/person\/de22247532aa8172abce3df9a1b12708","name":"Joe Arputhan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.securekloud.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/www.securekloud.com\/blog\/wp-content\/uploads\/2023\/04\/joe-arputhan-150x150.jpg","contentUrl":"https:\/\/www.securekloud.com\/blog\/wp-content\/uploads\/2023\/04\/joe-arputhan-150x150.jpg","caption":"Joe Arputhan"},"description":"Writer, researcher, content marketing evangelist, cloud and blockchain enthusiast.","sameAs":["https:\/\/www.linkedin.com\/in\/joe-arputhan-68b90523\/"],"url":"https:\/\/www.securekloud.com\/blog\/author\/joe-arputhan\/"}]}},"_links":{"self":[{"href":"https:\/\/www.securekloud.com\/blog\/wp-json\/wp\/v2\/posts\/82","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.securekloud.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.securekloud.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.securekloud.com\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/www.securekloud.com\/blog\/wp-json\/wp\/v2\/comments?post=82"}],"version-history":[{"count":10,"href":"https:\/\/www.securekloud.com\/blog\/wp-json\/wp\/v2\/posts\/82\/revisions"}],"predecessor-version":[{"id":1034,"href":"https:\/\/www.securekloud.com\/blog\/wp-json\/wp\/v2\/posts\/82\/revisions\/1034"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.securekloud.com\/blog\/wp-json\/wp\/v2\/media\/83"}],"wp:attachment":[{"href":"https:\/\/www.securekloud.com\/blog\/wp-json\/wp\/v2\/media?parent=82"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.securekloud.com\/blog\/wp-json\/wp\/v2\/categories?post=82"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.securekloud.com\/blog\/wp-json\/wp\/v2\/tags?post=82"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}