开发者

UIPicker crashing

开发者 https://www.devze.com 2023-04-09 04:46 出处:网络
My UIPicker is crashing if the NSArray of objects is greater than 3, with the following error: Terminating app due to uncaught exception \'NSInvalidArgumentException\', reason: \'-[NSAutoreleasePool

My UIPicker is crashing if the NSArray of objects is greater than 3, with the following error:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSAutoreleasePool pickerView:titleForRow:forComponent:]: unrecognized selector sent to instance

Here is my code for the functions:

- (void)viewDidLoad 
{
  [super viewDidLoad];
  // Do any additional setup after loading the view from its nib.

  self.glassPickerOptions = [[NSArray alloc] initWithObjects:@"3mm",@"4mm",@"DG4+4",@"DG4+6",nil];
  [glassPicker setFrame:CGRectMake(0, 0, 320, 162)];
  [glassPicker selectRow:1 inComponent:0 animated:NO];
}

- (NSInteger) numberOfComponentsInPickerView:(UIPickerView *)pickerView 
{
    return 1;
}

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
{
    NSInteger glassPickerOptionsCount = self.glassPickerOptions.count;
    NSLog(@"%i", glassPickerOptionsCount);
    return glassPickerOptionsCount;
}

- (NSString *)pickerView:(UIPickerView *)pickerView titleForRo开发者_StackOverflow社区w:(NSInteger)row forComponent:(NSInteger)component
{
    return (NSString*) [self.glassPickerOptions objectAtIndex:row];
}

Hopefully I havent missed anything. Thanks in advance


It seems that you overrelease your picker view, you can see this because the message is being sent to an autoreleasepool and not the object you expect, you should check out your retain/releases for your picker see whats going on, cant really tell from the code posted...

0

精彩评论

暂无评论...
验证码 换一张
取 消