Skip to content

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

@malgee012

Description

@malgee012

前提在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] 报错

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions