NSTimer

来源:互联网 发布:c语言找质数 编辑:程序博客网 时间:2024/05/03 10:08

- (void)someAction{NSTimeInterval timeInterval = 0.5;NSTimer *showTimer = [NSTimer scheduledTimerWithTimeInterval:timeInterval target:self selector:@selector(timerTest:) userInfo:nil repeats:NO];}-(void)timerTest:(NSTimer *)theTimer{    UIAlertView *timerAlert = [[UIAlertView alloc]initWithTitle:@"timer test!" message:nil delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil, nil];    [timerAlert show];    [theTimer  invalidate];}


-(void)someAction{      testView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 1024, 768)];      testView.backgroundColor = [UIColor clearColor];      testView.userInteractionEnabled = YES;      [self.view addSubview:testView];      [someThing reloadData];      [NSTimer scheduledTimerWithTimeInterval:1.5f target:self selector:@selector(timerTest:) userInfo:nil repeats:NO];  }  - (void)timerTest:(NSTimer*)theTimer  {      [testView removeFromSuperview];  }  



原创粉丝点击