Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

视图的高度与滚动有关系吗 #12

Open
LCBbest opened this issue Sep 30, 2018 · 10 comments
Open

视图的高度与滚动有关系吗 #12

LCBbest opened this issue Sep 30, 2018 · 10 comments

Comments

@LCBbest
Copy link

LCBbest commented Sep 30, 2018

image

pickerview的高度与底部视图的高度一样活着小的话 会多出一行。出现数组越界

@xiaozhuxiong121
Copy link
Owner

贴一下代码,我看下

@LCBbest
Copy link
Author

LCBbest commented Oct 16, 2018

image

有28行

image

在此设置的高度是250,底部view是210 如果 pick的高度是210的话 就会出来29行 虽然不显示,但是可以点击 点击之后报数组越界

@deanli08
Copy link

高度好像只要设置低于50 出现滚动在最后一行还可以向上滚动,界面卡到中间

@xiaozhuxiong121
Copy link
Owner

能弄个demo,我看看吗?

@AlwaysYang
Copy link

+1

@xslgithub
Copy link

+1
@deanli08

@xslgithub
Copy link

高度好像只要设置低于50 出现滚动在最后一行还可以向上滚动越界 ,界面卡到中间
然后设置初始化滚动好像无效?

@amycliny
Copy link

amycliny commented Aug 9, 2020

我似乎也是这个问题 越界crash了 请问解决了吗?

@RaInVis
Copy link

RaInVis commented Nov 13, 2020

  • (void)setupTableViewScroll:(UITableView *)tableView animated:(BOOL)animated {
    CGPoint offsetPoint = CGPointMake(tableView.contentOffset.x, tableView.contentOffset.y + self.rowHeight / 2);
    NSIndexPath *indexPath = [tableView indexPathForRowAtPoint: offsetPoint];
    if (indexPath.row >= self.datas.count) {
    indexPath = [NSIndexPath indexPathForRow:self.datas.count - 1 inSection:indexPath.section];
    }

    [tableView scrollToRowAtIndexPath: indexPath atScrollPosition: UITableViewScrollPositionTop animated:animated];
    }

  • (NSInteger)setupSelectedRow {
    NSInteger row = self.centerTableView.contentOffset.y / self.rowHeight + 0.5;
    if (self.isCycleScroll) {
    CGFloat posY = self.centerTableView.contentOffset.y + self.copyOffsetCount * self.rowHeight + self.rowHeight / 2;
    NSInteger count = posY / (self.datas.count * self.rowHeight);
    CGFloat newPosY = (self.centerTableView.contentOffset.y + self.copyOffsetCount * self.rowHeight) - (self.datas.count * self.rowHeight) * count;
    if (newPosY < 0) {
    newPosY = 0;
    }
    row = newPosY / self.rowHeight + 0.5;
    }
    if (row >= self.datas.count) {
    row = self.datas.count - 1;
    }

    return row;
    }
    PGPickerColumnView.m
    修改这两个方法就行了
    希望兄弟迭代下版本

@Marcello168
Copy link

+1 这个问题好像还有

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants