Closed RishabhTayal closed 9 years ago
Did you confirm that the count of items in your array is greater than the number returned from numberOfItemsInPickerView
?
What I did is, I deleted all the items in the array in your demo project. This makes it an empty array.
Ideally it should accept an empty array as datasource array in
- (NSUInteger)numberOfItemsInPickerView:(AKPickerView *)pickerView
Here is the code from your test project modified:
#import "AKViewController.h"
#import "AKPickerView.h"
@interface AKViewController () <AKPickerViewDataSource, AKPickerViewDelegate>
@property (nonatomic, strong) AKPickerView *pickerView;
@property (nonatomic, strong) NSArray *titles;
@end
@implementation AKViewController
- (void)viewDidLoad
{
[super viewDidLoad];
self.pickerView = [[AKPickerView alloc] initWithFrame:self.view.bounds];
self.pickerView.delegate = self;
self.pickerView.dataSource = self;
self.pickerView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self.view addSubview:self.pickerView];
self.pickerView.font = [UIFont fontWithName:@"HelveticaNeue-Light" size:20];
self.pickerView.highlightedFont = [UIFont fontWithName:@"HelveticaNeue" size:20];
self.pickerView.interitemSpacing = 20.0;
self.pickerView.fisheyeFactor = 0.001;
self.pickerView.pickerViewStyle = AKPickerViewStyle3D;
self.pickerView.maskDisabled = false;
self.titles = @[];
[self.pickerView reloadData];
}
#pragma mark - AKPickerViewDataSource
- (NSUInteger)numberOfItemsInPickerView:(AKPickerView *)pickerView
{
return [self.titles count];
}
- (NSString *)pickerView:(AKPickerView *)pickerView titleForItem:(NSInteger)item
{
return self.titles[item];
}
#pragma mark - AKPickerViewDelegate
- (void)pickerView:(AKPickerView *)pickerView didSelectItem:(NSInteger)item
{
NSLog(@"%@", self.titles[item]);
}
@end
I got it, it is a bug. I'm fixing it.
If you need, I would love to help you!
Thank you, but the work is done (b268b2972b1ec6a675d6bd8b04d7ca83b5fb9b58.) Again thanks a lot for your reporting!
@Akkyie You are welcome. Always happy to help.
It crashes on line #188 when number of items in datasource array is 0.