**我在單元格上顯示倒計時器,當我長按cell.but但問題是,當我點擊行定時器開始,但突然當我點擊第二個單元計時器停止前一個單元格,並啓動計時器新細胞,我點擊,但我需要的主要功能是我必須顯示運行前一個計時器和當前計時器。請任何人給我這種權利的方式。**如何在iphone中顯示細胞倒計時器?
-(void)handleLongPress:(UILongPressGestureRecognizer *)gestureRecognizer
{ AppDelegate *app=(AppDelegate *)[UIApplication sharedApplication].delegate;
CGPoint p = [gestureRecognizer locationInView:ChatTable];
NSIndexPath *indexPath = [ChatTable indexPathForRowAtPoint:p];
if ([[[userArray valueForKey:@"sender_id"] objectAtIndex:indexPath.row]isEqualToString: app.userId]) {
}
else{
if (gestureRecognizer.state == UIGestureRecognizerStateBegan)
{
if ([imageCache objectForKey:[NSString stringWithFormat:@"%d",indexPath.row]]==NULL) {
}
else
{
self.picId=[[userArray valueForKey:@"pic_id"] objectAtIndex:indexPath.row];
self.imageName=[[userArray valueForKey:@"imagename"] objectAtIndex:indexPath.row];
ChatTable.userInteractionEnabled=NO;
// self.navigationController.navigationBarHidden=YES;
image=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 480)];
self.pickerValue=[[userArray valueForKey:@"seconds"] objectAtIndex:indexPath.row];
image.image=[imageCache objectForKey:[NSString stringWithFormat:@"%d",indexPath.row]];
[self.view addSubview:image];
[self showTableTime:indexPath];
}
}
else if (gestureRecognizer.state == UIGestureRecognizerStateEnded) {
UITableViewCell * myCell = [ChatTable cellForRowAtIndexPath:indexpathForTimer];
UILabel * myLabel = (UILabel *)[myCell viewWithTag:101];
[email protected]"";
// self.navigationController.navigationBarHidden=NO;
[image removeFromSuperview];
}
}
}
-(void)showTableTime:(NSIndexPath *)indexPath
{
secondsLeft=[self.pickerValue integerValue];
indexpathForTimer=indexPath;
[self countDownTimer];
}
- (void)countDownTimer {
timer =[NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(updateCounter:) userInfo:nil repeats:YES];
}
- (void)updateCounter:(NSTimer *)theTimer {
UITableViewCell * myCell = [ChatTable cellForRowAtIndexPath:indexpathForTimer];
UILabel * myLabel = (UILabel *)[myCell viewWithTag:101];
if (secondsLeft >0) {
secondsLeft --;
UILabel * myLabel = (UILabel *)[myCell viewWithTag:101];
myLabel.text=[NSString stringWithFormat:@"0%d",secondsLeft];
}
else if(secondsLeft==0)
{
[self.image removeFromSuperview];
[timer invalidate];
ChatTable.userInteractionEnabled=YES;
[email protected]"";
[self SendRequsetToServerOfSeenImage];
}
else
{
}
}
我想實現相同的運行多個定時器,你成功了嗎? –