0
当用户按下按钮,然后另一个图像应该对图像的顶部和删除这是我tableview.i想再次当用户按重量是代码添加/删除按钮按下图像
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
CGRect prescriptionFrame=CGRectMake(100, 0, 150, 40);
UILabel *presTextLabel=[[UILabel alloc] initWithFrame:prescriptionFrame];
presTextLabel.font=[UIFont boldSystemFontOfSize:20];
CGRect tabletFrame=CGRectMake(150, 50, 100, 20);
UILabel *tabletTextLabel=[[UILabel alloc] initWithFrame:tabletFrame];
tabletTextLabel.font=[UIFont boldSystemFontOfSize:10];
CGRect noOfTabletFrame=CGRectMake(250, 40, 30, 30);
UILabel *noOfTabletTextLabel=[[UILabel alloc] initWithFrame:noOfTabletFrame];
noOfTabletTextLabel.font=[UIFont boldSystemFontOfSize:10];
cellButton = [UIButton buttonWithType:UIButtonTypeCustom];
cellButton.frame=CGRectMake(10,10 ,50,50);
presTextLabel.text=[appDelegate.prescriptionArray objectAtIndex:indexPath.row];
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(StartTimer)
forControlEvents:UIControlEventTouchUpInside];
cellButton.tag = indexPath.row;
[cell.contentView addSubview:presTextLabel];
[cell.contentView addSubview:tabletTextLabel];
[cell.contentView addSubview:noOfTabletTextLabel];
[cell.contentView addSubview:cellButton];
[presTextLabel release];
[tabletTextLabel release];
return cell;
}
尝试将你的代码段更好。这是不是真的可读.. –
你试图改变每一行的'cellButton'UIButton的图像,当一个按钮在其他地方被按下,然后再次按下该按钮时删除或改回它? – mattacular