Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 从UITableViewCell按钮设置计时器_Iphone - Fatal编程技术网

Iphone 从UITableViewCell按钮设置计时器

Iphone 从UITableViewCell按钮设置计时器,iphone,Iphone,我想在UITableViewCell中使用UIButton设置时间。当我点击一个按钮时,计时器工作,但当我点击两个或更多按钮时,计时器不会停止 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { tabletTextLabel.text=[appDelegate.tabletArray objectAtIndex:indexPa

我想在UITableViewCell中使用UIButton设置时间。当我点击一个按钮时,计时器工作,但当我点击两个或更多按钮时,计时器不会停止

  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    tabletTextLabel.text=[appDelegate.tabletArray objectAtIndex:indexPath.row];
    noOfTabletTextLabel.text=[appDelegate.noOfTabletsArray objectAtIndex:indexPath.row];



[cellButton setImage:[appDelegate.imageArray objectAtIndex:indexPath.row] forState:UIControlStateNormal];
    [cellButton addTarget:self action:@selector(CellButtonClick:) forControlEvents:UIControlEventTouchUpInside];
    cellButton.tag = indexPath.row;


// cell.accessoryView = cellButton;
    [cell.contentView addSubview:presTextLabel];
    [cell.contentView addSubview:tabletTextLabel];
    [cell.contentView addSubview:noOfTabletTextLabel];
    [cell.contentView addSubview:cellButton];
        return cell;
}

在startTimer中,您可以检查计时器是否已在运行,并在启动新计时器之前使其无效

if (timer) [timer invalidate];
timer = nil;
timer = [NSTimer scheduledTimerWithTimeInterval:....];

谢谢老兄…嘿,你能帮忙吗..嘿,当用户按下按钮时,另一个图像会出现在该图像的顶部,当用户再次按下时会被删除..请帮我解决..至于按钮问题,只需为将UIImageView的隐藏属性设置为“是”或“否”的按钮指定一个@selector操作。您可以使用类型为UIButtonTypeCustom的不可见UIButtonof覆盖UIImageView,并使用@selector操作将其隐藏。
if (timer) [timer invalidate];
timer = nil;
timer = [NSTimer scheduledTimerWithTimeInterval:....];