YIem`s Blog -心比天高命比纸薄-链接找不到的请在站内搜索内容!

iOS-UI-UIKit框架-UIKit-事件手势

#import "ViewController.h"

@interface ViewController ()
@property (nonatomic, retain) UILabel *label;
@end

@implementation ViewController


// 长按手势
UILongPressGestureRecognizer *longGR = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longAction:)];
[self.label addGestureRecognizer:longGR];
[longGR release];
// 旋转手势
UIRotationGestureRecognizer *potaGR = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(potaAction:)];
[self.label addGestureRecognizer:potaGR];
[potaGR release];
// 捏合手势
UIPinchGestureRecognizer *pinGR = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pinAction:)];
[self.label addGestureRecognizer:pinGR];
[pinGR release];
// 平移手势
UIPanGestureRecognizer *panGR = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panAction:)];
[self.label addGestureRecognizer:panGR];
[panGR release];
// 轻扫手势
UISwipeGestureRecognizer *swipeGR = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(swipeAction:)];
[self.view addGestureRecognizer:swipeGR];
[swipeGR release];
// 屏幕边缘轻扫;
UIScreenEdgePanGestureRecognizer *screGR = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(screenAction:)];
[self.view addGestureRecognizer:screGR];
[screGR release];

}

// 响应者链
// -> 内核 -> 系统 -> 当前APP -> 传递到最前沿的
// 在一级一级向回传, 直到遇见一个有响应能力的视图进行响应, 并且不在传
// 如所有视图都不具备响应能力, 则丢失事件
// 如有父子关系的视图, 关闭了响应能力(UserInterActionRnabled)事件,则之后的传递会被阻止, 无父子关系的视图关闭了响应能力 依然会向后传递
// UIIMagreView和UIlabel的默认响应能力是关闭的 x







当前页面是本站的「Google AMP」版。查看和发表评论请点击:完整版 »