Assertion failure on picker view

后端 未结 2 961
情歌与酒
情歌与酒 2020-12-16 11:10

I\'m getting an assertion failure while scrolling a picker view w/ zero data(zero rows). While scrolling the picker view I\'m getting this crash. Testing on iOS 6

相关标签:
2条回答
  • 2020-12-16 11:51

    I've the same problem

    I don't know reason why it is happen,

    but it can be fixed in ios6 (how it works in ios5 I didn't check):

    - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
    {
        if ([self getCount] == 0)
            return 1;
         return [self getCount];
    }
    
    - (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:   (NSInteger)component reusingView:(UIView *)view {
       if ([self getCount] == 0)
           return nil;
    }
    
    0 讨论(0)
  • 2020-12-16 12:09

    The answer is actually very simple! After having some trouble with this myself, I discovered that you must set the delegate and the dataSource to the view controller that the picker view is connected to.

    0 讨论(0)
提交回复
热议问题