如果对象的UIPicker
大于3,则我的NSArray
崩溃,并出现以下错误:
由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:' - [NSAutoreleasePool pickerView:titleForRow:forComponent:]:发送到实例的无法识别的选择器
这是我的函数代码:
- (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 titleForRow:(NSInteger)row forComponent:(NSInteger)component
{
return (NSString*) [self.glassPickerOptions objectAtIndex:row];
}
希望我没有错过任何事情。提前致谢
答案 0 :(得分:0)
你似乎过度发布你的选择器视图,你可以看到这个,因为邮件被发送到autoreleasepool而不是你期望的对象,你应该检查你的选择器的保留/发布,看看发生了什么,真的不能从发布的代码中说出来......