文件名称:iOS长按按钮
文件大小:110KB
文件格式:ZIP
更新时间:2016-05-02 07:38:37
长按按钮
下面是实现的核心逻辑,具体例子详见附件 self.button=[UIButton buttonWithType:UIButtonTypeCustom]; [self.button addTarget:self action:@selector(buttonTouchUpInside) forControlEvents:UIControlEventTouchUpInside]; [self.button addTarget:self action:@selector(buttonTouchUpOutside) forControlEvents:UIControlEventTouchUpOutside]; [self.button addTarget:self action:@selector(buttonTouchDown) forControlEvents:UIControlEventTouchDown]; //当按下按钮以后调用该方法,增加一个延迟。 - (void)buttonTouchDown { [self performSelector:@selector(lazyButtontouchDown) withObject:nil afterDelay:self.minimumPressDuration]; } -(void)lazyButtontouchDown { } //当离开按钮的时候取消所调用的方法 - (void)buttonTouchUpInside { [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(lazyButtontouchDown) object:nil]; }
【文件预览】:
UIButtonLongPressed
----.DS_Store(6KB)
----UIButtonLongPressed.xcodeproj()
--------project.xcworkspace()
--------xcuserdata()
--------project.pbxproj(13KB)
----UIButtonLongPressed()
--------LongPressButton.h(1KB)
--------.DS_Store(6KB)
--------en.lproj()
--------UIButtonLongPressed-Prefix.pch(341B)
--------main.m(355B)
--------UIButtonLongPressed-Info.plist(1KB)
--------QLViewController.h(234B)
--------LongPressButton.m(4KB)
--------QLAppDelegate.h(387B)
--------QLViewController.m(1KB)
--------QLAppDelegate.m(3KB)
----.git()
--------logs()
--------info()
--------index(1KB)
--------COMMIT_EDITMSG(15B)
--------objects()
--------HEAD(23B)
--------config(111B)
--------refs()
--------branches()
--------hooks()
--------description(73B)