限制一段时间内对button只能点按一次
来源:互联网 发布:loading windows files 编辑:程序博客网 时间:2024/06/08 18:20
#import "ViewController.h"
@implementation ViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (id)init
{
self = [super init];
if(self)
{
}
return self;
}
- (void)viewDidLoad
{
UIButton * btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
btn.frame = CGRectMake(50, 50, 100, 30);
[btn addTarget:self action:@selector(btnPress:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:btn];
[NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(getCurrentTime) userInfo:nil repeats:YES];
isLock = NO;
last = 60;
}
-(void)btnPress:(UIButton *)btn
{
if (isLock == NO)
{
NSLog(@"hello");
isLock = YES;
tempDate = [NSDate dateWithTimeIntervalSinceNow:0];
NSDateFormatter * dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"ss"];
NSString * strDate = [dateFormatter stringFromDate:tempDate];
last = [strDate intValue];
isLock = YES ;
}
}
-(void)getCurrentTime
{
NSDate * date = [NSDate dateWithTimeIntervalSinceNow:0];
NSDateFormatter * dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"ss"];
NSString * strDate = [dateFormatter stringFromDate:date];
NSInteger nowDate = [strDate intValue];
if(nowDate < last)
{
nowDate = nowDate + 60;
}
if(nowDate - last > 1)
{
// NSLog(@"nowDate = %d",nowDate);
// NSLog(@"last = %d",last);
// NSLog(@"nowDate - last = %d",nowDate - last);
isLock = NO;
}
}
@end
- 限制一段时间内对button只能点按一次
- 限制时间内只能点击一次并且做提示 thinkphp
- js限制一段时间内频繁点击提交
- 一定时间内,只能发送一次请求
- 限定时间内同一ip只能访问一次
- ExtJS Button调用Ext.window.Window后,只能点开一次,第二次就点不开
- 如何设置button只能点击一次
- MySQL 对一段时间内每天数据统计案例--sql优化
- MySQL 对一段时间内每天数据统计案例--sql优化
- 只能提交一次 限制 function submitonce(theform)
- 一段时间内的迷惑
- 查找一段时间内日志
- 获取一段时间内数据
- aspx 提交按钮只能点一次
- 如何限制应用程序在同一时刻只能运行一次?
- .NET限制程序一次只能运行一个实例
- 限制用户只能登录一次的最佳方案
- 根据已有的cron表达式列出以后一段时间内的时间触发点列表
- javascript学习系列02(变量,循环,基础语法)
- VC6.0使用的18个技巧
- 扩展方法
- 动态树模板 (陈首元ppt)
- 可视化通讯(以Anychat为例子)
- 限制一段时间内对button只能点按一次
- VB网络操作学习笔记
- SSH结合spring事务管理配置文件
- visio画UML用例图没有include关系的解决方法
- javascript学习系列03(分支判断与循环)
- 漫谈项目管理1——九子夺嫡1
- Java SE基础部分-05.数组与方法
- 基于ckeditor的在JSP中显示文本编辑页面
- 在Win8下无法拖动文件的解决办法