- 浏览: 458312 次
- 性别:
- 来自: 广州
文章分类
- 全部博客 (538)
- C/C++ Primer (69)
- Objective-C Primer (102)
- Python Primer (19)
- JavaScript Primer (1)
- Java Primer (37)
- PHP Primer (17)
- 泛 Linux (37)
- Shell Script (21)
- APUE (21)
- UNP__1&2 (19)
- NetWork (7)
- Oracle周边 (38)
- Mysql里边 (6)
- Windows技 (9)
- 简单算法 & 数据结构 (14)
- 设计模式 (6)
- GTK历程 (12)
- 工具使用 (25)
- 杂事 (23)
- 一些概念 (17)
- Web方面 (10)
- myCodeTools (9)
- ^未 竟$ (13)
- 硬件通信 (2)
- Games (1)
最新评论
http://hi.baidu.com/bunsman/blog/item/1b1930de4e43a74895ee3756.html
http://hi.baidu.com/%B0%D9ii%D6%AAi%B5%C0/blog/item/04bfba11fb47a2c5f7039ea8.html
http://blog.csdn.net/pjk1129/article/details/6824810
UIResponder 响应者链
长按View
如果双击确定偵測失败才會触发单击
[singleRecognizer requireGestureRecognizerToFail:doubleRecognizer];
@protocol UIGestureRecognizerDelegate <NSObject>
@optional
// called when a gesture recognizer attempts to transition out of UIGestureRecognizerStatePossible. returning NO causes it to transition to UIGestureRecognizerStateFailed
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer;
// called when the recognition of one of gestureRecognizer or otherGestureRecognizer would be blocked by the other
// return YES to allow both to recognize simultaneously. the default implementation returns NO (by default no two gestures can be recognized simultaneously)
//
// note: returning YES is guaranteed to allow simultaneous recognition. returning NO is not guaranteed to prevent simultaneous recognition, as the other gesture's delegate may return YES
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer;
// called before touchesBegan:withEvent: is called on the gesture recognizer for a new touch. return NO to prevent the gesture recognizer from seeing this touch
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch;
@end
UITapGestureRecognizer 点击动作
UIPinchGestureRecognizer 捏/掐动作
UIRotationGestureRecognizer 旋转动作
UISwipeGestureRecognizer 轻扫动作
UIPanGestureRecognizer 平移动作
UILongPressGestureRecognizer 长按动作
http://hi.baidu.com/%B0%D9ii%D6%AAi%B5%C0/blog/item/04bfba11fb47a2c5f7039ea8.html
http://blog.csdn.net/pjk1129/article/details/6824810
UIResponder 响应者链
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event; - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event; - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
长按View
UILongPressGestureRecognizer *longPressGR = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)]; longPressGR.minimumPressDuration = 0.2; [self addGestureRecognizer:longPressGR]; [longPressGR release]; - (void)handleLongPress:(UIGestureRecognizer *)gestureRecognizer { NSLog(@"LONG PRESS"); }
如果双击确定偵測失败才會触发单击
[singleRecognizer requireGestureRecognizerToFail:doubleRecognizer];
@protocol UIGestureRecognizerDelegate <NSObject>
@optional
// called when a gesture recognizer attempts to transition out of UIGestureRecognizerStatePossible. returning NO causes it to transition to UIGestureRecognizerStateFailed
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer;
// called when the recognition of one of gestureRecognizer or otherGestureRecognizer would be blocked by the other
// return YES to allow both to recognize simultaneously. the default implementation returns NO (by default no two gestures can be recognized simultaneously)
//
// note: returning YES is guaranteed to allow simultaneous recognition. returning NO is not guaranteed to prevent simultaneous recognition, as the other gesture's delegate may return YES
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer;
// called before touchesBegan:withEvent: is called on the gesture recognizer for a new touch. return NO to prevent the gesture recognizer from seeing this touch
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch;
@end
UITapGestureRecognizer 点击动作
UIPinchGestureRecognizer 捏/掐动作
UIRotationGestureRecognizer 旋转动作
UISwipeGestureRecognizer 轻扫动作
UIPanGestureRecognizer 平移动作
UILongPressGestureRecognizer 长按动作
发表评论
-
float equal
2013-05-23 18:21 818- (BOOL)floatA:(float)f1 equalB ... -
Coding Guidelines for Cocoa
2013-05-17 16:53 666参考: https://developer.apple.com ... -
Cell
2013-05-16 14:32 788- (void)tableView:(UITableView ... -
Object-C编程规范
2013-05-15 10:49 7351.参考苹果的文档 “Coding Guidelines fo ... -
MacPorts
2013-02-28 18:12 613http://blog.csdn.net/lynjay/art ... -
KVC/KVO 监听对象属性变化
2013-01-10 23:09 7401http://blog.csdn.net/a6472953/a ... -
ios Associative 扩展属性
2013-01-08 16:45 1537@dynamic和@synthesize http://blo ... -
ObjC Dynamic
2013-01-08 15:21 773原文:http://www.onevcat.com/2012/ ... -
UITableView & UITextField
2012-11-08 00:35 835keyboard event ---------------- ... -
UIWebView
2012-10-24 11:06 744http://hi.baidu.com/wei_1123/it ... -
Device orientation
2012-10-15 16:20 746- (BOOL)shouldAutorotateToInter ... -
system notification
2012-10-12 15:22 626for UIApplication These notifi ... -
NSZombies
2012-08-09 08:51 667NSZombies搞定EXC_BAD_ACCESS http: ... -
Quartz 2D Programming Guide
2012-07-17 00:51 593Quartz 2D 内容不少啊 Graphics Trans ... -
NSCache
2012-07-12 14:25 755http://thenewself.blog.163.com/ ... -
NSCoding
2012-07-12 13:39 959@protocol NSCoding - (void ... -
分析 crash 报告的方法
2012-07-12 01:15 584http://blog.csdn.net/toss156/ar ... -
Multi-touch
2012-07-11 23:33 724智能与灵活与工作量>_< http://www.o ... -
iOS的多核编程和内存管理
2012-07-11 18:14 716http://anxonli.iteye.com/blog/1 ... -
NSCopying
2012-07-10 15:54 519http://www.apple.com.cn/develop ...
相关推荐
手势识别(GestureRecognizer)是iOS开发中的重要组成部分,它允许用户通过特定的手势与应用程序进行交互。在iOS系统中,UIKit框架提供了多种内置的手势识别器类,如UIPanGestureRecognizer(拖动)、...
guard let view = gestureRecognizer.view else { return } switch gestureRecognizer.state { case .began: // 手势开始时,记录初始位置 initialCenter = view.center case .changed: // 手势变化时,...
Swift5.2中的手势识别(GestureRecognizer)是iOS应用开发中常用的一种交互技术,它允许用户通过简单的触摸或滑动操作来触发特定的功能。在iOS、macOS等Apple平台的开发中,手势识别扮演着至关重要的角色,使得应用...
UIView *view = gestureRecognizer.view; if (gestureRecognizer.state == UIGestureRecognizerStateBegan || gestureRecognizer.state == UIGestureRecognizerStateChanged) { CGFloat scale = ...
这个“ios-可移动改变的大小的View.zip”压缩包提供了一个实现这一功能的示例,主要关注的是手势交互。在这个项目中,重点是`MoveLabel`,一个可以移动和调整大小的UILabel子类。 首先,我们来深入理解手势交互...
在iOS开发中,自定义视图(Custom View)和手势识别(Gesture Recognition)是两个重要的技术领域,尤其在创建交互式、动态的应用时显得尤为重要。本文将深入探讨如何基于Stanford大学iOS 7课程中的第7课内容,实现...
guard let translation = gestureRecognizer.translation(in: view) else { return } if gestureRecognizer.state == .began { drawerViewOriginalPosition = drawerView.frame.origin } else if ...
guard let view = gestureRecognizer.view else { return } // 在这里处理点击事件,例如改变视图的颜色或执行其他操作 } ``` 为了使布局更具动态性,我们还可以添加重力行为(`UIGravityBehavior`),使视图在屏幕...
- iOS SDK提供了多种手势识别器(GestureRecognizer),如UIPanGestureRecognizer、UITapGestureRecognizer等,可以监听用户的滑动、点击等操作。在这个Demo中,开发者可能使用了UIPanGestureRecognizer来检测用户...
view.transform = view.transform.scaledBy(x: gestureRecognizer.scale, y: gestureRecognizer.scale) gestureRecognizer.scale = 1 } } ``` 同样,设置代理并实现相应的同步识别方法。 ### 结论 iOS手势识别...
let translation = gestureRecognizer.translation(in: view) view.center = CGPoint(x: view.center.x + translation.x, y: view.center.y + translation.y) gestureRecognizer.setTranslation(CGPoint.zero, in...
7. **手势冲突处理**:有时下拉刷新可能与TableView的其他手势(如滚动)产生冲突,这时需要正确配置和管理手势识别器(GestureRecognizer)以确保它们协同工作。 通过以上技术,我们可以实现iOS应用中从上往下拉...
pdfView.scale(to: gestureRecognizer.scale) } ``` 5. **读取PDF目录**: - `PDFDocument`的`pages`属性是一个`PDFPage`数组,表示PDF的所有页面。PDF的目录通常包含在PDF的元数据中,可以使用`PDFOutlineRoot...
guard let view = gestureRecognizer.view else { return } switch gestureRecognizer.state { case .began: // 手势开始时记录初始位置 break case .changed: // 更新截图框的位置 let translation = ...
guard let translation = gestureRecognizer.translation(in: view) else { return false } return abs(translation.x) > abs(translation.y) && translation.x } ``` 4. 在`handlePanGesture`方法中,我们需要...
let translation = gestureRecognizer.translation(in: view) drawerView.center.x += translation.x gestureRecognizer.setTranslation(CGPoint.zero, in: view) case .ended, .cancelled: let velocity = ...
8. **添加手势识别**:开发者可以添加手势识别器(GestureRecognizer)到Scroll View,以便实现自定义的用户交互,比如双击放大等。 9. **嵌套Scroll View**:有时我们需要在一个Scroll View内部再嵌套另一个Scroll...
.center = CGPoint(x: gestureRecognizer.view!.center.x + translation.x, y: gestureRecognizer.view!.center.y + translation.y) gestureRecognizer.setTranslation(.zero, in: view) } } ``` 这段代码中,`...
3. **重写识别方法**:在自定义手势类中,你需要实现`- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)...
let translation = gestureRecognizer.translation(in: view) if abs(translation.y) > threshold { // threshold是预设的关闭阈值 // 关闭视图的逻辑 } } } ``` 关闭视图的方式取决于你的具体需求。可以简单...