美文网首页
UITableView相关问题

UITableView相关问题

作者: 阿木小丸子 | 来源:发表于2018-02-01 10:04 被阅读0次

    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;

    }

    相关文章

      网友评论

          本文标题:UITableView相关问题

          本文链接:https://www.haomeiwen.com/subject/whorzxtx.html