如何在UITableView中選擇單元格後不再選擇或選擇其他單元格時消除創建的視圖。iOS:UITableView澄清
假設我有下面的didSelectRowAtIndexPath方法的代碼:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
CGSize cellSize = [tableView cellForRowAtIndexPath:indexPath].frame.size;
UIView *selectionView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, (int)cellSize.width, (int)(cellSize.height + 100))];
selectionView.layer.borderWidth = 2;
[[tableView cellForRowAtIndexPath:indexPath]addSubview:selectionView];
}
現在,我想,當我專注於另一種細胞再次刪除創建selectionView和創建它到我聚焦單元。該問題是當我第一次選擇一個單元格時,它完美地工作,但是當我選擇另一個單元格時,從前一個單元格創建的selectionView仍然不會消失,並且它已經複製了該視圖。我想如何解決這個問題?需要建議.. :(感謝..
感謝aadhira ......嘿嘿,我們有相同的猜測它工作..:D – Aldee 2012-01-31 04:47:36