别人写的 代码,

当component 一直是零的时候,那么 就 修改 row的数值了。。。

- (void)selectRow:(NSInteger)row inComponent:(NSInteger)component animated:(BOOL)animated

{

    [super selectRow:row inComponent:component animated:animated];

    if (row < 0) {

        row = 0;

    }

    else if (row > [self numberOfRowsInComponent:component]) {

        row = [self numberOfRowsInComponent:component] - 1;

    }

    int lastIndex = [self selectedRowInComponent:component];

    if (lastIndex != row) {

        PickerCellView* cellView = (PickerCellView*)[self viewForRow:lastIndex forComponent:component];

        cellView.selected = NO;

        cellView = (PickerCellView*)[self viewForRow:row forComponent:component];

        cellView.selected = YES;

    }

    [self.selectionDicsetValue:[NSNumbernumberWithInt:row] forKey:[NSStringstringWithFormat:@"%d", component]];

}

posted @ 2013-07-03 18:19  路在脚下,  阅读(210)  评论(0编辑  收藏  举报