我有2个不同的TableVC和共同的细胞。我可以将单元格从一个复制到另一个,但可能还有另一种存档方法吗?我不想使用.xib
答案 0 :(得分:0)
如果您想要与单元格完全相同,那么您可以执行此操作。我只是截取屏幕截图。
-(void)copyCell
{
UITableViewCell * aCell = [_tblView cellForRowAtIndexPath:[_tblView indexPathForSelectedRow]];
UIGraphicsBeginImageContext(aCell.frame.size);
[aCell.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *aCellImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
UIImageView * imageView = [[UIImageView alloc] initWithImage:aCellImage];
imageView.frame = CGRectMake(aCell.frame.origin.x, aCell.frame.origin.y-offset, aCell.frame.size.width, aCell.frame.size.height);
[self.view addSubview:imageView]; --->> change the self.view to your next tableView cell
}