测试已测试 | ✓ |
语言语言 | Obj-CObjective C |
许可证 | MIT |
发布上次发布 | 2014年12月 |
由 Seivan Heidari 维护。
此 Pod 被
SHUIKitBlocks
使用,作为许多组件的一部分,覆盖了从 Foundation、UIKit、CoreLocation、GameKit、MapKit 和 iOS 应用程序架构的其他方面中遗漏的补丁。
当目标消失时,手势会自动移除,因此不需要清理 - Swizzle Free(™)
直接从便捷类选择器创建块
在手势识别器上添加额外的块
移除特定块 - 如果它是最后一个块,则会从目标中移除手势识别器
包含手势上所有活动块的 NSSet
pod 'SHGestureRecognizerBlocks'
将这些放入特定文件或项目前缀文件中
#import "UIGestureRecognizer+SHGestureRecognizerBlocks.h"
或者
#import "SHGestureRecognizerBlocks.h"
使用 SHGestureRecognizerBlocks,您可以设置自动移除的块而不是使用选择器
UITapGestureRecognizer * tapRecognizer = [UITapGestureRecognizer SH_gestureRecognizerWithBlock:^(UIGestureRecognizer *sender, UIGestureRecognizerState state, CGPoint location) {
NSLog(@"callback");
}];
[self.view addGestureRecognizer:tapRecognizer];
或者如果您想添加额外的块
UITapGestureRecognizer * tapRecognizer = [UITapGestureRecognizer alloc] init];
SHGestureRecognizerBlock block = ^(UIGestureRecognizer *sender, UIGestureRecognizerState state, CGPoint location) {
NSLog(@"CALLBACK block1");
};
SHGestureRecognizerBlock block2 = ^(UIGestureRecognizer *sender, UIGestureRecognizerState state, CGPoint location) {
NSLog(@"CALLBACK block2");
};
[tapRecognizer SH_addBlock:block];
[tapRecognizer SH_addBlock:block2];
[self.view addGestureRecognizer:tapRecognizer];
-(void)SH_removeBlock:(SHGestureRecognizerBlock)theBlock;
[tapGesture SH_removeBlock:block];
-(void)SH_removeAllBlocks;
[tapGesture SH_removeAllBlocks];
@property(nonatomic,readonly) NSSet * SH_blocks;
for(SHGestureRecognizerBlock block in tapGesture.SH_blocks) {
}
与其他手势(如滑动、平移和长按)很好的兼容。
[[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(performBlockAction:)];
如果你在项目中使用了 SHGestureRecognizerBlocks,我非常愿意了解相关信息。
电子邮箱: [email protected]
推特: @seivanheidari
SHGestureRecognizerBlocks © 2013 Seivan,可在 MIT 许可证下自由分发。请参阅 LICENSE.md
文件。