1、UITableView滑動時超出自身的frame?
? ? ?self.tableView.clipsToBounds = YES;(默認為YES)
2、點擊cell會多選?
NSIndexPath *lastPath;
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
? ? ? ? ? ? NSInteger row = [indexPath row];
? ? ? ? ? ? NSInteger oldRow = [lastPath row];
? ? ? ? ? ? if (row == oldRow && lastPath!=nil) {
? ? ? ? ? ? ? ? houseTableViewCell.accessoryType = UITableViewCellAccessoryCheckmark;
? ? ? ? ? ? }else{
? ? ? ? ? ? ? ? houseTableViewCell.accessoryType = UITableViewCellAccessoryNone;
? ? ? ? ? ? }
? ? ? ? ? ? [houseTableView selectRowAtIndexPath:lastPath animated:YES scrollPosition:UITableViewScrollPositionNone];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
? ? ? ? ? ?NSInteger newRow = [indexPath row];
? ? ? ? ? ? NSInteger oldRow = (lastPath !=nil)?[lastPath row]:-1;
? ? ? ? ? ? if (newRow != oldRow) {
? ? ? ? ? ? ? ? UITableViewCell *newCell = [tableView cellForRowAtIndexPath:indexPath];
? ? ? ? ? ? ? ? newCell.accessoryType = UITableViewCellAccessoryCheckmark;
? ? ? ? ? ? ? ? UITableViewCell *oldCell = [tableView cellForRowAtIndexPath:lastPath];
? ? ? ? ? ? ? ? oldCell.accessoryType = UITableViewCellAccessoryNone;
? ? ? ? ? ? ? ? lastPath = indexPath;
}