
iOS Mobile Technologies Overview and Gestures Implementation Guide
Explore an introduction to Apple mobile technologies with a focus on iOS development practices, including a detailed explanation of implementing gestures in applications for a seamless user experience. Dive into the fundamentals of touch events interpretation and learn how to enhance user interactions through predefined touch events and gesture recognizers.
Download Presentation

Please find below an Image/Link to download the presentation.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.
You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.
The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.
E N D
Presentation Transcript
Introduction to Apple mobile technologies- I393 IT College, Andres K ver, 2016-2017 Spring Web: http://enos.itcollege.ee/~akaver/apple Skype: akaver Email: akaver@itcollege.ee
iOS - Practice 2 Tic-Tac-Toe Model, UI
iOS - Gestures 3 It is possible to get raw touch events but these are hard to interpret Your own interpretation of touch events might not be consistent with rest of world bad user experience Use predefined touch events Gestures Gestures are recognized by abstract class UIGestureRecognizer Add gesture recognizer to UIView Provide a method to handle that gesture (usually not the same UIView) Adding recognizer is usually done by Controller (sometimes by UIView itself) Gesture handler is either UIView or Controller
iOS - Gestures 4 Adding gesture recognizer TicTacToe tile is at least tap-able for recognizing players next move @IBOutlet weak var SingleTile: UITile! { didSet { let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(ViewController.handleTap(recognizer:))) SingleTile.addGestureRecognizer(tapGestureRecognizer) } } target : self- ie current controller action: func to call
iOS - Gestures 5 Gesture handler Needs gesture specific information Each concrete subclass provides special methods and variables for this type of gesture UITapGestureRecognizer numberOfTapsRequired, numberOfTouchesRequired UIPanGestureRecognizer maximumNumberOfTouches, minimumNumberOfTouches func translation(in view: UIView?) -> CGPoint func setTranslation(_ translation: CGPoint, in view: UIView?) func velocity(in view: UIView?) -> CGPoint Abstract superclass provides state information var state: UIGestureRecogizerState { get } .possible, .began, .changed, .ended, .recognized, .failed, .cancelled
iOS - Gestures 6 UITapGestureRecognizer UIPinchGestureRecognizer UIRotationGestureRecognizer UISwipeGestureRecognizer UIPanGestureRecognizer UIScreenEdgePanGestureRecognizer UILongPressGestureRecognizer
iOS - Gestures 7 Handler for pan gesture func handlePan(recognizer: UIPanGestureRecognizer){ switch recognizer.state { case .changed, .ended: let translation = recognizer.translation(in: SingleTile) // do something in view with translation.x and .y recognizer.setTranslation(CGPoint.zero, in: SingleTile) default: break } }