Seven major iOS gestures (translation, kneading, scanning, and screen edge scanning)Gestures are easy to use and can be divided into two steps:
(4) Translation gestures
(5) kneading gestures
(6) Scanning gestures
:
-(UIView *) HitTest: (cgpoint) point withevent: (Uievent *) event {
//Determine whether the current control can receive the touch event
if ( self.userinteractionenabled = NO | | Self.hidden = = YES | | Self.alpha
However, there are drawbacks to using the touches method to monitor touch events, such as customizing view, so after iOS3.2 Apple launched the gesture recognition function Uigesturerecognizer. Uigesturerecognizer is an abstract class whose subclasses can handle
iOS development expands the potential error of drag gestures in-xibFirst, error descriptionCustomizing a class to encapsulate a toolbarBuild the Xib and add a drag gesture. Code for the host controller: loading toolbarsEncapsulating toolbars and gesture-dragging listening events At this time to run the program, the program directly crashes, error is as follows: Note:
Today, I learned the methods and applications of gestures in iOS programming, and there are many controls in the screen page, some controls can have click events and users interact directly, can execute corresponding methods, such as Textfield,button,uisegmentcontroll, But static Lableuiimageview and so on need to turn on the interactive switch, add the response gesture to realize the interaction.Liu Guobin
click on a picture- (void) Tapclick: (UITapGestureRecognizer *) sender{[Self.view BringSubviewToFront:sender.view];}//implement mobile gestures, similar to Touchmove- (void) Move: (Uipangesturerecognizer *) sender{//a fixed notationCgpoint point =[Sender TranslationInView:self.view]; Sender.view.center= Cgpointmake (sender.view.center.x + point.x, Sender.view.center.y +point.y); [Sender Settranslation:cgpointzero InView:self.view];}//the ability to i
13.1 event Overview
13.2 touch events
13.3 gestures
13.1 event Overview
An event is the object that the system continuously sends to the application when the user's fingers touch the screen and move on the screen.
The system passes an event to an object that can be processed according to a specific path.
In iOS, A uitouch object represents a touch, and a uievent object represents an event. The event objec
1. ConceptGestures are all events that occur when you touch the screen with one or more fingers, until your finger leaves the screen. This gesture exists regardless of how long the gesture lasts, as long as one or more fingers remain on the screen.Touch refers to the behavior of placing your finger on the screen of an iOS device, dragging or lifting it from the screen. The number of touches involved in a gesture equals the number of fingers that are s
First, error descriptionCustomizing a class to encapsulate a toolbarBuild the Xib and add a drag gesture. Code for the host controller: loading toolbarsEncapsulating toolbars and gesture-dragging listening events At this time to run the program, the program directly crashes, error is as follows: Note: Gestures do not have a Superview method, Superview is UIView method, indicating that we mistakenly put the gesture object as a uiview to use.Debug to
1 Preface
Gestures are actually a combination of touch events. gesture event recognition must be added to a uiview class. Multiple gesture identifiers can be added to a single view. Once some gesture actions are captured on this interface, this view will pass the gesture action to other gesture identifiers.Some touch events require support from the mobile phone system. The following are six gesture identifiers provided by
If you are using the storyboard layout, and the use of the system's return button, it will automatically have a sliding back effect, but I believe you do the project, is generally used by the custom return button, so I paste a few lines of code to see how to implement the system comes with the sliding back.First, create a custom return button, and then add the [self.navigationItem setLeftBarButtonItem:backBarItem];And then- (void) Viewwilldisappear: (BOOL) Animated {[Super viewwilldisappear:ani
//Viewcontroller.mui- gesture and control exercises//Created by Jzq_mac on 15/7/24.Copyright (c) year Jzq_mac. All rights reserved.//#import "ViewController.h"@interface Viewcontroller (){Uiimageview *image;Uiimageview *image1;UILabel *label;Nsarray *colorlist;Nsarray *imgelist;UISlider *slider;}@end@implementation Viewcontroller-(void) Viewdidload {[superviewdidload]; self. View. BackgroundColor = [uicolorgraycolor]; colorlist = @[[UicolorBluecolor],[UicolorBrowncolor],[UicolorYellowcolor],[U
Using gestures is simple and divided into two steps:
Creates a gesture instance. When creating gestures, specify a callback method that is called when the gesture starts, changes, or ends.
Added to the view that needs to be recognized. Each gesture corresponds to only one view, and when the screen touches within the bounds of the view, if the gesture is the same as the reservation, the callback
In the development process, often use, need to close a page of the gesture return function.//Disable return gestures- (void) Viewdidappear: (BOOL) animated{[Super viewdidappear:animated]; //Disable return gestures if([Self.navigationcontroller respondstoselector: @selector (Interactivepopgesturerecognizer)]) {Self.navigation Controller.interactivePopGestureRecognizer.enabled=NO; }}//Turn on
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.