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]
}