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

isCycleScroll设置为YES情况下崩溃 #17

Open
malgee012 opened this issue Jun 14, 2019 · 1 comment
Open

isCycleScroll设置为YES情况下崩溃 #17

malgee012 opened this issue Jun 14, 2019 · 1 comment

Comments

@malgee012
Copy link

malgee012 commented Jun 14, 2019

前提在isCycleScroll为YES 接着设置第一个程序崩溃,isCycleScroll为NO的情况程序正常执行

[self.pickerView selectRow:0 inComponent:0 animated:true];

报错位置

- (void)selectRow:(NSInteger)row animated:(BOOL)animated {
    NSInteger newRow = row;
    if (self.isCycleScroll) {
        newRow = row - self.copyOffsetCount;
    }
    if (animated) {
        NSIndexPath *indexPath = [NSIndexPath indexPathForRow:newRow inSection:0];
        [self.centerTableView scrollToRowAtIndexPath:indexPath atScrollPosition:UITableViewScrollPositionTop animated:true];
        self.selectedRow = row;
        self.isSelectedRow = true;
    }else {
        self.centerTableView.contentOffset = CGPointMake(0, newRow * self.rowHeight);
        [self scrollViewDidEndDecelerating: self.centerTableView];
    }
}

这行代码导致的错误
newRow = row - self.copyOffsetCount;

设置第一个位置0的时候,newRow值为负数
[NSIndexPath indexPathForRow:newRow inSection:0] 报错

@a714857512
Copy link

现在还会报错吗?我试了一下没有崩溃了

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

2 participants