{"id":1776,"date":"2019-10-17T06:37:00","date_gmt":"2019-10-17T06:37:00","guid":{"rendered":"https:\/\/mobilecoderz.com\/blog\/?p=1776"},"modified":"2023-07-24T11:01:48","modified_gmt":"2023-07-24T05:31:48","slug":"how-to-add-multiple-gesture-recognizers-to-uiview","status":"publish","type":"post","link":"https:\/\/mobilecoderz.com\/blog\/how-to-add-multiple-gesture-recognizers-to-uiview\/","title":{"rendered":"How to Add Multiple Gesture Recognizers to UI View?"},"content":{"rendered":"<p style=\"text-align: justify;\"><span style=\"font-weight: 400; font-family: arial, helvetica, sans-serif;\">In iOS app development, gestures play a very influential role in creating an engaging user interface. It basically contains taps, pinches, pans, or rotations for user input in navigation. Gesture functionality allows users to move, click or tap on their preferred area of the iOS mobile app screen.<\/span><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400; font-family: arial, helvetica, sans-serif;\">Many iOS developers often face difficulty in adding multiple gesture recognizers to UIView. Gesture recognizers are a powerful and effective tool for adding user gesture functionality into the iOS app like tap, pinch, swipe, slide, and rotate.\u00a0<\/span><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: arial, helvetica, sans-serif;\"><span style=\"font-weight: 400;\">It enables users to execute actions such as triggering animations or view changes on the app screen. Hence, it is important to accurately add <span style=\"color: #003366;\"><a style=\"color: #003366;\" href=\"https:\/\/stackoverflow.com\/questions\/41918256\/handling-multiple-gesturerecognizers\" target=\"_blank\" rel=\"noopener nofollow\">multiple gesture recognizers to UIView<\/a><\/span> to engage users. Since we are an expert <\/span><span style=\"color: #003366;\"><a style=\"color: #003366;\" href=\"https:\/\/mobilecoderz.com\/iphone-app-development\/\" target=\"_blank\" rel=\"noopener\"><em><span style=\"text-decoration: underline;\"><strong>iOS app development company<\/strong><\/span><\/em><\/a><\/span><span style=\"font-weight: 400;\">, we know how to add multiple gesture recognizers to UIView effectively. In this blog, we will tell you how to do it.\u00a0<\/span><\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400; font-family: arial, helvetica, sans-serif;\">So let&#8217;s get started<\/span><\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/mobilecoderz.com\/blog\/how-to-add-multiple-gesture-recognizers-to-uiview\/#Overview_of_UIGesture_Recognizer_in_iOS_Development\" >Overview of UIGesture Recognizer in iOS Development<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/mobilecoderz.com\/blog\/how-to-add-multiple-gesture-recognizers-to-uiview\/#Conclusion\" >Conclusion<\/a><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"Overview_of_UIGesture_Recognizer_in_iOS_Development\"><\/span><span style=\"font-family: arial, helvetica, sans-serif; color: #003366;\"><strong>Overview of UIGesture Recognizer in iOS Development<\/strong><\/span><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\"><span style=\"font-family: arial, helvetica, sans-serif;\"><span style=\"font-weight: 400;\">Before you start implementing multiple gesture recognizers to UIView, you should know why [<\/span><i><span style=\"font-weight: 400;\">UIGestureRecognizer]<\/span><\/i><span style=\"font-weight: 400;\"> is a useful tool and how to utilize it.\u00a0<\/span><\/span><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: arial, helvetica, sans-serif;\"><span style=\"font-weight: 400;\">Prior to this functionality, it was really difficult to add multiple gesture recognizer features in iOS app development. For instance, if there is a need for detecting a swipe, then <\/span><span style=\"color: #003366;\"><a style=\"color: #003366;\" href=\"https:\/\/mobilecoderz.com\/hire-ios-app-developers\/\" target=\"_blank\" rel=\"noopener\"><em><span style=\"text-decoration: underline;\"><strong>iOS app developers<\/strong><\/span><\/em><\/a><\/span><span style=\"font-weight: 400;\"> have had to register for notifications such as [<\/span><i><span style=\"font-weight: 400;\">touchesBegan]<\/span><\/i><span style=\"font-weight: 400;\">, [<\/span><i><span style=\"font-weight: 400;\">touchesMoved]<\/span><\/i><span style=\"font-weight: 400;\">, and [<\/span><i><span style=\"font-weight: 400;\">touchesEnded]<\/span><\/i><span style=\"font-weight: 400;\"> for each touch in [<\/span><i><span style=\"font-weight: 400;\">UIView]<\/span><\/i><span style=\"font-weight: 400;\">.\u00a0<\/span><\/span><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: arial, helvetica, sans-serif;\"><span style=\"font-weight: 400;\">This technique creates subtle bugs and inconsistency across iOS applications. It happens because iOS developers have had to write a little different code to recognize those touches. And therefore, adding multiple gestures takes a lot of work which increases time in the <\/span><span style=\"font-weight: 400;\">iOS development<\/span><span style=\"font-weight: 400;\">.\u00a0<\/span><\/span><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400; font-family: arial, helvetica, sans-serif;\">Then Apple brought changes in Xcode to support iOS developers in adding feature features to iOS apps. With the current update, developers can easily create feature recognizer functionality in iOS mobile applications that detect common gestures. For example rotations, swipes, pans,\u00a0 taps, long presses, and pinches.\u00a0<\/span><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400; font-family: arial, helvetica, sans-serif;\">This updated feature helps developers in writing less code but also enables the app to work efficiently.\u00a0 Hence, adding multiple gesture recognizer features to UIView in iOS app development is quite easier than before.\u00a0<\/span><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400; font-family: arial, helvetica, sans-serif;\">Now, let&#8217;s start how to add multiple gesture recognizers to UIView in iOS apps.\u00a0<\/span><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400; font-family: arial, helvetica, sans-serif;\">There are Seven Types of Gestures That Support iOS<\/span><\/p>\n<ol style=\"text-align: justify;\">\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-family: arial, helvetica, sans-serif;\"><b>Tap Gesture Recognizer<\/b><span style=\"font-weight: 400;\">: Performing an action for tapping the UIObject.<\/span><\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-family: arial, helvetica, sans-serif;\"><b>Pinch Gesture Recognizer:<\/b><span style=\"font-weight: 400;\"> Used when need the zoom in and zoom out feature<\/span><\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-family: arial, helvetica, sans-serif;\"><b>Rotation Gesture Recognizer:<\/b><span style=\"font-weight: 400;\"> To perform the rotation on UIObject<\/span><\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-family: arial, helvetica, sans-serif;\"><b>Swipe Gesture Recognizer:<\/b><span style=\"font-weight: 400;\"> Four kinds of swipe gestures i.e. Top, left. Bottom, right<\/span><\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-family: arial, helvetica, sans-serif;\"><b>Pan Gesture Recognizer:<\/b><span style=\"font-weight: 400;\"> Help when we need to drag the UIObject anywhere on UIWindow<\/span><\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-family: arial, helvetica, sans-serif;\"><b>Screen Edge Pan Gesture Recognizer:<\/b><span style=\"font-weight: 400;\"> Special gesture used for 3-D touch<\/span><\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-family: arial, helvetica, sans-serif;\"><b>Long Press:<\/b><span style=\"font-weight: 400;\"> Generally used in the scenario when pressing the UIObject will pop up certain options<\/span><\/span><\/li>\n<\/ol>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400; font-family: arial, helvetica, sans-serif;\">Here is a simple declaration of the UIViewController with a single UIImageView in it<\/span><\/p>\n<pre><span style=\"font-family: arial, helvetica, sans-serif;\"><b>class<\/b><span style=\"font-weight: 400;\"> GesturePlayingController: UIViewController {<\/span>\r\n<span style=\"font-weight: 400;\">\r\n\u00a0\u00a0\u00a0\u00a0<\/span><b>let<\/b><span style=\"font-weight: 400;\"> myImageView: UIImageView = {<\/span>\r\n<span style=\"font-weight: 400;\">\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$0.contentMode = .scaleAspectFill<\/span>\r\n<span style=\"font-weight: 400;\">\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$0.image = UIImage(named: \"testImage\")<\/span>\r\n<span style=\"font-weight: 400;\">\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0$0.isUserInteractionEnabled = <\/span><b>true<\/b>\r\n<span style=\"font-weight: 400;\">\u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><b>return<\/b><span style=\"font-weight: 400;\"> $0<\/span>\r\n<span style=\"font-weight: 400;\">\r\n\u00a0\u00a0\u00a0\u00a0}(UIImageView())<\/span><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span>\r\n<span style=\"font-weight: 400;\">\r\n\u00a0\u00a0\u00a0\u00a0<\/span><b>override<\/b> <b>func<\/b><span style=\"font-weight: 400;\"> viewDidLoad() {<\/span>\r\n<span style=\"font-weight: 400;\">\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><b>super<\/b><span style=\"font-weight: 400;\">.viewDidLoad()<\/span>\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0}\r\n\r\n<\/span><\/span><\/pre>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400; font-family: arial, helvetica, sans-serif;\">We have declared the simple UIImageView with lazy initialization with its user interaction property enabled so that we can add multiple gestures to it.<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: arial, helvetica, sans-serif;\"><span style=\"font-weight: 400;\">Since no rocket science has been used so far, now we can add the gesture recognizer one by one to imageView.<\/span><span style=\"font-weight: 400;\">\u00a0<\/span><\/span><\/p>\n<pre><span style=\"font-family: arial, helvetica, sans-serif;\"><b>func<\/b><span style=\"font-weight: 400;\"> addGesture() {<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><b>let<\/b><span style=\"font-weight: 400;\"> pan = UIPanGestureRecognizer(target: <\/span><b>self<\/b><span style=\"font-weight: 400;\">, action: <\/span><b>#selector<\/b><span style=\"font-weight: 400;\">(panImage))<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><b>let<\/b><span style=\"font-weight: 400;\"> rotate = UIRotationGestureRecognizer(target: <\/span><b>self<\/b><span style=\"font-weight: 400;\">, action: <\/span><b>#selector<\/b><span style=\"font-weight: 400;\">(handleRotation))<\/span><span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><b>let<\/b><span style=\"font-weight: 400;\"> pinch = UIPinchGestureRecognizer(target: <\/span><b>self<\/b><span style=\"font-weight: 400;\">, action: <\/span><b>#selector<\/b><span style=\"font-weight: 400;\">(pinchImage))<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0myImageView.addGestureRecognizer(pinch)<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0myImageView.addGestureRecognizer(pan)<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0myImageView.addGestureRecognizer(rotate)<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0}\r\n<\/span>\r\n<b>@objc<\/b> <b>func<\/b><span style=\"font-weight: 400;\"> panImage(<\/span><b>_<\/b><span style=\"font-weight: 400;\"> recognizer: UIPanGestureRecognizer) {\u00a0\u00a0\u00a0\u00a0<\/span>\r\n\r\n<span style=\"font-weight: 400;\">}<\/span>\r\n\u00a0\r\n<b>@objc<\/b> <b>func<\/b><span style=\"font-weight: 400;\"> pinchImage(<\/span><b>_<\/b><span style=\"font-weight: 400;\"> recognizer: UIPinchGestureRecognizer) {\u00a0<\/span>\r\n\r\n<span style=\"font-weight: 400;\">}<\/span>\r\n\r\n<b>@objc<\/b> <b>func<\/b><span style=\"font-weight: 400;\"> handleRotation(recognizer:UIRotationGestureRecognizer){<\/span>\r\n\r\n<span style=\"font-weight: 400;\">}<\/span><\/span><\/pre>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400; font-family: arial, helvetica, sans-serif;\">While adding the gesture recognizer to UIImageView, we need to give the selector that generally functions when the particular types of gestures are being performed.<\/span><\/p>\n<div style=\"background-color: #f6f6f6; padding: 15px; margin: 15px 0px; border-left: 4px solid #1e3957; font-size: 18px; text-align: justify;\">\n<div style=\"color: #303030; font-weight: 600; position: absolute;\"><span style=\"font-family: arial, helvetica, sans-serif;\">Also Read:<\/span><\/div>\n<div style=\"padding-left: 100px;\"><span style=\"font-family: arial, helvetica, sans-serif;\"><a class=\"colorlink\" style=\"text-decoration: underline; font-style: italic; font-weight: 600;\" href=\"https:\/\/mobilecoderz.com\/blog\/javascript-vs-dart-a-quick-comparison-to-choose-dominating-one\/\" target=\"_blank\" rel=\"noopener\">JavaScript vs Dart: A Quick Comparison To Choose Dominating One<\/a><\/span><\/div>\n<\/div>\n<p style=\"text-align: justify;\"><span style=\"font-family: arial, helvetica, sans-serif;\"><span style=\"font-weight: 400;\">Let us start with a simple <\/span><b>PAN Gesture Recognizer<\/b><\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400; font-family: arial, helvetica, sans-serif;\">For moving the imageView in UIView, we need to set the translation from its initial position. <\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: arial, helvetica, sans-serif;\"><span style=\"font-weight: 400;\">For example<\/span><span style=\"font-weight: 400;\">\u00a0<\/span><\/span><\/p>\n<pre><span style=\"font-family: arial, helvetica, sans-serif;\"><b>  @objc<\/b> <b>func<\/b><span style=\"font-weight: 400;\"> panImage(<\/span><b>_<\/b><span style=\"font-weight: 400;\"> recognizer: UIPanGestureRecognizer) {<\/span>\r\n<span style=\"font-weight: 400;\">\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><b>let<\/b><span style=\"font-weight: 400;\"> translation = recognizer.translation(in: view)<\/span>\r\n<span style=\"font-weight: 400;\">\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><b>guard<\/b> <b>let<\/b><span style=\"font-weight: 400;\"> view = recognizer.view <\/span><b>else<\/b><span style=\"font-weight: 400;\"> { <\/span><b>return<\/b><span style=\"font-weight: 400;\"> }<\/span>\r\n<span style=\"font-weight: 400;\">\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0view.center = CGPoint(x: view.center.x + translation.x, y: view.center.y + translation.y)<\/span>\r\n<span style=\"font-weight: 400;\">\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0recognizer.setTranslation(CGPoint.zero, in: view)<\/span>\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0}<\/span><\/span><\/pre>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: arial, helvetica, sans-serif;\"><span style=\"font-weight: 400;\">After setting the translation, reset the translation to zero so that the next time when you perform the <\/span><b>PAN<\/b><span style=\"font-weight: 400;\"> on the imageView, it should start with zero.<\/span><\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"font-family: arial, helvetica, sans-serif;\"><span style=\"font-weight: 400;\">Similarly, we can perform the <\/span><b>PINCH and ROTATION Gesture <\/b><span style=\"font-weight: 400;\">on imageView.<\/span><\/span><\/p>\n<pre><span style=\"font-family: arial, helvetica, sans-serif;\"><b>@objc<\/b> <b>func<\/b><span style=\"font-weight: 400;\"> pinchImage(<\/span><b>_<\/b><span style=\"font-weight: 400;\"> recognizer: UIPinchGestureRecognizer) {<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><b>guard<\/b> <b>let<\/b><span style=\"font-weight: 400;\"> view = recognizer.view <\/span><b>else<\/b><span style=\"font-weight: 400;\">{<\/span><b>return<\/b><span style=\"font-weight: 400;\">}<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0view.transform = view.transform.scaledBy(x: recognizer.scale, y: recognizer.scale)<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0recognizer.scale = 1.0<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0}<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0<\/span><b>@objc<\/b> <b>func<\/b><span style=\"font-weight: 400;\"> handleRotation(recognizer:UIRotationGestureRecognizer){<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><b>guard<\/b> <b>let<\/b><span style=\"font-weight: 400;\"> view = recognizer.view <\/span><b>else<\/b><span style=\"font-weight: 400;\"> {<\/span><b>return<\/b><span style=\"font-weight: 400;\">}<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0view.transform = view.transform.rotated(by: recognizer.rotation)<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/span><b>if<\/b><span style=\"font-weight: 400;\"> recognizer.rotation == 0 { <\/span><b>return<\/b><span style=\"font-weight: 400;\"> }<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0radian = recognizer.rotation<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0recognizer.rotation = 0<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0}<\/span><\/span><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"Conclusion\"><\/span><span style=\"font-family: arial, helvetica, sans-serif; color: #003366;\"><b>Conclusion<\/b><\/span><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400; font-family: arial, helvetica, sans-serif;\">Adding multiple gesture recognizers to UIView in iOS app development is now easier and smoother than before. Developers now have to follow simple steps and write less code to implement the features. However, with growing innovations in UI development, users now expect more attractive and seamless features in UI.\u00a0<\/span><\/p>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\"><span style=\"font-weight: 400; font-family: arial, helvetica, sans-serif;\">Therefore, to ensure you build an iOS app with intuitive UI features, you should try to create the app with an expert. And MobileCoderz is the top iOS app development company that has the industry&#8217;s most qualified and experienced iOS developers who can build really innovative and engaging UI features for your iOS mobile app.<\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>In iOS app development, gestures play a very influential role in creating an engaging user interface. It basically contains taps, pinches, pans, or rotations for user input in navigation. Gesture functionality allows users to move, click or tap on their preferred area of the iOS mobile app screen. &nbsp; Many iOS developers often face difficulty [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":8640,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18,782,16],"tags":[33,38,40,39,37],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How To Add Multiple Gesture Recognizers To UIView | MobileCoderz<\/title>\n<meta name=\"description\" content=\"Here is a quick way to learn how to add multiple gesture recognizers to UIview i.e simultaneously to single view. Tap on the link to know more..\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/mobilecoderz.com\/blog\/how-to-add-multiple-gesture-recognizers-to-uiview\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How To Add Multiple Gesture Recognizers To UIView | MobileCoderz\" \/>\n<meta property=\"og:description\" content=\"Here is a quick way to learn how to add multiple gesture recognizers to UIview i.e simultaneously to single view. Tap on the link to know more..\" \/>\n<meta property=\"og:url\" content=\"https:\/\/mobilecoderz.com\/blog\/how-to-add-multiple-gesture-recognizers-to-uiview\/\" \/>\n<meta property=\"og:site_name\" content=\"MobileCoderz\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/MobileCoderz\/\" \/>\n<meta property=\"article:published_time\" content=\"2019-10-17T06:37:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-07-24T05:31:48+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/mobilecoderz.com\/blog\/wp-content\/uploads\/2019\/10\/gesture-recognition-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"720\" \/>\n\t<meta property=\"og:image:height\" content=\"404\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Abhishek Shukla\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@mobilecoderz\" \/>\n<meta name=\"twitter:site\" content=\"@mobilecoderz\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Abhishek Shukla\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/mobilecoderz.com\/blog\/how-to-add-multiple-gesture-recognizers-to-uiview\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/mobilecoderz.com\/blog\/how-to-add-multiple-gesture-recognizers-to-uiview\/\"},\"author\":{\"name\":\"Abhishek Shukla\",\"@id\":\"https:\/\/mobilecoderz.com\/blog\/#\/schema\/person\/a9f6a2d671fc3df3019578029ae0c0f5\"},\"headline\":\"How to Add Multiple Gesture Recognizers to UI View?\",\"datePublished\":\"2019-10-17T06:37:00+00:00\",\"dateModified\":\"2023-07-24T05:31:48+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/mobilecoderz.com\/blog\/how-to-add-multiple-gesture-recognizers-to-uiview\/\"},\"wordCount\":752,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/mobilecoderz.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/mobilecoderz.com\/blog\/how-to-add-multiple-gesture-recognizers-to-uiview\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/mobilecoderz.com\/blog\/wp-content\/uploads\/2019\/10\/gesture-recognition-1.png\",\"keywords\":[\"MobileCoderz\",\"Multiple Tap Gesture Recognizers\",\"UIGestureRecognizers\",\"UITapGestureRecognizers\",\"UIView\"],\"articleSection\":[\"Featured\",\"iOS App Development\",\"Technology\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/mobilecoderz.com\/blog\/how-to-add-multiple-gesture-recognizers-to-uiview\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/mobilecoderz.com\/blog\/how-to-add-multiple-gesture-recognizers-to-uiview\/\",\"url\":\"https:\/\/mobilecoderz.com\/blog\/how-to-add-multiple-gesture-recognizers-to-uiview\/\",\"name\":\"How To Add Multiple Gesture Recognizers To UIView | MobileCoderz\",\"isPartOf\":{\"@id\":\"https:\/\/mobilecoderz.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/mobilecoderz.com\/blog\/how-to-add-multiple-gesture-recognizers-to-uiview\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/mobilecoderz.com\/blog\/how-to-add-multiple-gesture-recognizers-to-uiview\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/mobilecoderz.com\/blog\/wp-content\/uploads\/2019\/10\/gesture-recognition-1.png\",\"datePublished\":\"2019-10-17T06:37:00+00:00\",\"dateModified\":\"2023-07-24T05:31:48+00:00\",\"description\":\"Here is a quick way to learn how to add multiple gesture recognizers to UIview i.e simultaneously to single view. Tap on the link to know more..\",\"breadcrumb\":{\"@id\":\"https:\/\/mobilecoderz.com\/blog\/how-to-add-multiple-gesture-recognizers-to-uiview\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/mobilecoderz.com\/blog\/how-to-add-multiple-gesture-recognizers-to-uiview\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/mobilecoderz.com\/blog\/how-to-add-multiple-gesture-recognizers-to-uiview\/#primaryimage\",\"url\":\"https:\/\/mobilecoderz.com\/blog\/wp-content\/uploads\/2019\/10\/gesture-recognition-1.png\",\"contentUrl\":\"https:\/\/mobilecoderz.com\/blog\/wp-content\/uploads\/2019\/10\/gesture-recognition-1.png\",\"width\":720,\"height\":404,\"caption\":\"gesture-recognition\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/mobilecoderz.com\/blog\/how-to-add-multiple-gesture-recognizers-to-uiview\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/mobilecoderz.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Add Multiple Gesture Recognizers to UI View?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/mobilecoderz.com\/blog\/#website\",\"url\":\"https:\/\/mobilecoderz.com\/blog\/\",\"name\":\"MobileCoderz\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/mobilecoderz.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/mobilecoderz.com\/blog\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/mobilecoderz.com\/blog\/#organization\",\"name\":\"MobileCoderz Technologies Pvt Ltd\",\"url\":\"https:\/\/mobilecoderz.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/mobilecoderz.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/mobilecoderz.com\/blog\/wp-content\/uploads\/2016\/02\/logo-1-2.png\",\"contentUrl\":\"https:\/\/mobilecoderz.com\/blog\/wp-content\/uploads\/2016\/02\/logo-1-2.png\",\"width\":100,\"height\":63,\"caption\":\"MobileCoderz Technologies Pvt Ltd\"},\"image\":{\"@id\":\"https:\/\/mobilecoderz.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/MobileCoderz\/\",\"https:\/\/x.com\/mobilecoderz\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/mobilecoderz.com\/blog\/#\/schema\/person\/a9f6a2d671fc3df3019578029ae0c0f5\",\"name\":\"Abhishek Shukla\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/mobilecoderz.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/382f2fc042f61a502301cbe02c82a2a8?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/382f2fc042f61a502301cbe02c82a2a8?s=96&d=mm&r=g\",\"caption\":\"Abhishek Shukla\"},\"description\":\"Co-founder of MobileCoderz Technologies and a skilled IT consultant with exemplary brilliancy in software engineering. He likes sharing informative blogs mentioning ins &amp; outs of IT consulting with a pinch of trending technologies &amp; techniques. His dexterity in project management led him to shine as a successful entrepreneur &amp; emerging blogger.\",\"sameAs\":[\"https:\/\/mobilecoderz.com\/blog\"],\"url\":\"https:\/\/mobilecoderz.com\/blog\/author\/abhishekmobilecoderz-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How To Add Multiple Gesture Recognizers To UIView | MobileCoderz","description":"Here is a quick way to learn how to add multiple gesture recognizers to UIview i.e simultaneously to single view. Tap on the link to know more..","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:\/\/mobilecoderz.com\/blog\/how-to-add-multiple-gesture-recognizers-to-uiview\/","og_locale":"en_US","og_type":"article","og_title":"How To Add Multiple Gesture Recognizers To UIView | MobileCoderz","og_description":"Here is a quick way to learn how to add multiple gesture recognizers to UIview i.e simultaneously to single view. Tap on the link to know more..","og_url":"https:\/\/mobilecoderz.com\/blog\/how-to-add-multiple-gesture-recognizers-to-uiview\/","og_site_name":"MobileCoderz","article_publisher":"https:\/\/www.facebook.com\/MobileCoderz\/","article_published_time":"2019-10-17T06:37:00+00:00","article_modified_time":"2023-07-24T05:31:48+00:00","og_image":[{"width":720,"height":404,"url":"https:\/\/mobilecoderz.com\/blog\/wp-content\/uploads\/2019\/10\/gesture-recognition-1.png","type":"image\/png"}],"author":"Abhishek Shukla","twitter_card":"summary_large_image","twitter_creator":"@mobilecoderz","twitter_site":"@mobilecoderz","twitter_misc":{"Written by":"Abhishek Shukla","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/mobilecoderz.com\/blog\/how-to-add-multiple-gesture-recognizers-to-uiview\/#article","isPartOf":{"@id":"https:\/\/mobilecoderz.com\/blog\/how-to-add-multiple-gesture-recognizers-to-uiview\/"},"author":{"name":"Abhishek Shukla","@id":"https:\/\/mobilecoderz.com\/blog\/#\/schema\/person\/a9f6a2d671fc3df3019578029ae0c0f5"},"headline":"How to Add Multiple Gesture Recognizers to UI View?","datePublished":"2019-10-17T06:37:00+00:00","dateModified":"2023-07-24T05:31:48+00:00","mainEntityOfPage":{"@id":"https:\/\/mobilecoderz.com\/blog\/how-to-add-multiple-gesture-recognizers-to-uiview\/"},"wordCount":752,"commentCount":1,"publisher":{"@id":"https:\/\/mobilecoderz.com\/blog\/#organization"},"image":{"@id":"https:\/\/mobilecoderz.com\/blog\/how-to-add-multiple-gesture-recognizers-to-uiview\/#primaryimage"},"thumbnailUrl":"https:\/\/mobilecoderz.com\/blog\/wp-content\/uploads\/2019\/10\/gesture-recognition-1.png","keywords":["MobileCoderz","Multiple Tap Gesture Recognizers","UIGestureRecognizers","UITapGestureRecognizers","UIView"],"articleSection":["Featured","iOS App Development","Technology"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/mobilecoderz.com\/blog\/how-to-add-multiple-gesture-recognizers-to-uiview\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/mobilecoderz.com\/blog\/how-to-add-multiple-gesture-recognizers-to-uiview\/","url":"https:\/\/mobilecoderz.com\/blog\/how-to-add-multiple-gesture-recognizers-to-uiview\/","name":"How To Add Multiple Gesture Recognizers To UIView | MobileCoderz","isPartOf":{"@id":"https:\/\/mobilecoderz.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/mobilecoderz.com\/blog\/how-to-add-multiple-gesture-recognizers-to-uiview\/#primaryimage"},"image":{"@id":"https:\/\/mobilecoderz.com\/blog\/how-to-add-multiple-gesture-recognizers-to-uiview\/#primaryimage"},"thumbnailUrl":"https:\/\/mobilecoderz.com\/blog\/wp-content\/uploads\/2019\/10\/gesture-recognition-1.png","datePublished":"2019-10-17T06:37:00+00:00","dateModified":"2023-07-24T05:31:48+00:00","description":"Here is a quick way to learn how to add multiple gesture recognizers to UIview i.e simultaneously to single view. Tap on the link to know more..","breadcrumb":{"@id":"https:\/\/mobilecoderz.com\/blog\/how-to-add-multiple-gesture-recognizers-to-uiview\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/mobilecoderz.com\/blog\/how-to-add-multiple-gesture-recognizers-to-uiview\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/mobilecoderz.com\/blog\/how-to-add-multiple-gesture-recognizers-to-uiview\/#primaryimage","url":"https:\/\/mobilecoderz.com\/blog\/wp-content\/uploads\/2019\/10\/gesture-recognition-1.png","contentUrl":"https:\/\/mobilecoderz.com\/blog\/wp-content\/uploads\/2019\/10\/gesture-recognition-1.png","width":720,"height":404,"caption":"gesture-recognition"},{"@type":"BreadcrumbList","@id":"https:\/\/mobilecoderz.com\/blog\/how-to-add-multiple-gesture-recognizers-to-uiview\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/mobilecoderz.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to Add Multiple Gesture Recognizers to UI View?"}]},{"@type":"WebSite","@id":"https:\/\/mobilecoderz.com\/blog\/#website","url":"https:\/\/mobilecoderz.com\/blog\/","name":"MobileCoderz","description":"","publisher":{"@id":"https:\/\/mobilecoderz.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/mobilecoderz.com\/blog\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/mobilecoderz.com\/blog\/#organization","name":"MobileCoderz Technologies Pvt Ltd","url":"https:\/\/mobilecoderz.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/mobilecoderz.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/mobilecoderz.com\/blog\/wp-content\/uploads\/2016\/02\/logo-1-2.png","contentUrl":"https:\/\/mobilecoderz.com\/blog\/wp-content\/uploads\/2016\/02\/logo-1-2.png","width":100,"height":63,"caption":"MobileCoderz Technologies Pvt Ltd"},"image":{"@id":"https:\/\/mobilecoderz.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/MobileCoderz\/","https:\/\/x.com\/mobilecoderz"]},{"@type":"Person","@id":"https:\/\/mobilecoderz.com\/blog\/#\/schema\/person\/a9f6a2d671fc3df3019578029ae0c0f5","name":"Abhishek Shukla","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/mobilecoderz.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/382f2fc042f61a502301cbe02c82a2a8?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/382f2fc042f61a502301cbe02c82a2a8?s=96&d=mm&r=g","caption":"Abhishek Shukla"},"description":"Co-founder of MobileCoderz Technologies and a skilled IT consultant with exemplary brilliancy in software engineering. He likes sharing informative blogs mentioning ins &amp; outs of IT consulting with a pinch of trending technologies &amp; techniques. His dexterity in project management led him to shine as a successful entrepreneur &amp; emerging blogger.","sameAs":["https:\/\/mobilecoderz.com\/blog"],"url":"https:\/\/mobilecoderz.com\/blog\/author\/abhishekmobilecoderz-com\/"}]}},"_links":{"self":[{"href":"https:\/\/mobilecoderz.com\/blog\/wp-json\/wp\/v2\/posts\/1776"}],"collection":[{"href":"https:\/\/mobilecoderz.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mobilecoderz.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mobilecoderz.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mobilecoderz.com\/blog\/wp-json\/wp\/v2\/comments?post=1776"}],"version-history":[{"count":12,"href":"https:\/\/mobilecoderz.com\/blog\/wp-json\/wp\/v2\/posts\/1776\/revisions"}],"predecessor-version":[{"id":9727,"href":"https:\/\/mobilecoderz.com\/blog\/wp-json\/wp\/v2\/posts\/1776\/revisions\/9727"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/mobilecoderz.com\/blog\/wp-json\/wp\/v2\/media\/8640"}],"wp:attachment":[{"href":"https:\/\/mobilecoderz.com\/blog\/wp-json\/wp\/v2\/media?parent=1776"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mobilecoderz.com\/blog\/wp-json\/wp\/v2\/categories?post=1776"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mobilecoderz.com\/blog\/wp-json\/wp\/v2\/tags?post=1776"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}