Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/116.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
Ios 在tableview单元格中使用开始暂停操作。如果我选择开始,它将显示暂停,并再次滚动表格,在tableview中显示开始_Ios_Objective C_Iphone - Fatal编程技术网

Ios 在tableview单元格中使用开始暂停操作。如果我选择开始,它将显示暂停,并再次滚动表格,在tableview中显示开始

Ios 在tableview单元格中使用开始暂停操作。如果我选择开始,它将显示暂停,并再次滚动表格,在tableview中显示开始,ios,objective-c,iphone,Ios,Objective C,Iphone,行动 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return pavanobjets.count; } - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSStrin

行动

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return pavanobjets.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *cellidentifier = @"Cell";

    Cell = (myCell *)[tableView dequeueReusableCellWithIdentifier:cellidentifier];
    if (Cell == nil) {
        NSArray *topLevel = [[NSBundle mainBundle] loadNibNamed:@"myCell" owner:self options:nil];

        for (id curretobj in topLevel) { 
            if ([curretobj isKindOfClass:[UITableViewCell class]]) {    
                Cell = (myCell *)curretobj;
                break;
            }
        }

        Cell.lblData.text = [pavanobjets objectAtIndex:indexPath.row];
        [Cell.btnStart addTarget:self action:@selector(likeEvent:) forControlEvents:UIControlEventTouchUpInside];
        // Cell.btnStart.tag=indexPath.row;  
    }
    return Cell;
}

设置图像后重新加载该特定单元格

- (void)likeEvent:(UIButton *)sender
{  
    UIButton *likeButton = (UIButton *)sender;

    if (likeButton.isSelected) {
        [likeButton  setImage:[UIImage imageNamed:@"start.png"] forState:UIControlStateNormal];
    } else {
        [likeButton  setImage:[UIImage imageNamed:@"pause.png"] forState:UIControlStateSelected];
    }
    [likeButton  setSelected:!likeButton.isSelected];
    NSLog(@"like:%d",likeButton.isSelected);
}

设置图像后重新加载该特定单元格

- (void)likeEvent:(UIButton *)sender
{  
    UIButton *likeButton = (UIButton *)sender;

    if (likeButton.isSelected) {
        [likeButton  setImage:[UIImage imageNamed:@"start.png"] forState:UIControlStateNormal];
    } else {
        [likeButton  setImage:[UIImage imageNamed:@"pause.png"] forState:UIControlStateSelected];
    }
    [likeButton  setSelected:!likeButton.isSelected];
    NSLog(@"like:%d",likeButton.isSelected);
}
  - (void)likeEvent:(UIButton *)sender {
            NSInteger row = your desired row
            NSInteger section = your desired section

            NSIndexPath *indexPath = [[NSIndexPath alloc] indexPathForItem:row section:section];
            [tableView reloadRowsAtIndexPaths:@[indexPath] 
                          withRowAnimation:UITableViewRowAnimationNone]
        }