解决方法
您可以在rowDidSelect Delegate方法中添加新视图,
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; UIView *myView = [[UIView alloc] initWithFrame:CGRectMake(10.0f,10.0f,100.0f,30.0f)]; [myView setTag:-1]; [cell addSubview:myView]; }
同样实现DidDeselectRowatindexpath
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath]; UIView *myView = [cell viewWithTag:-1]; [myView removeFromSuperview]; }