2013-04-22 81 views
1

我有一個視圖,需要等待,直到從Web服務檢索數據,然後更新UI選取器視圖。當我在等待響應,如果用戶滾動選擇器視圖的應用程序崩潰,我得到lldb錯誤。任何理由?ios:UIPickerView lldb錯誤,當我嘗試滾動

這裏是我的代碼:

@interface LocavoreRetroSecondViewController() 

@end 

@implementation LocavoreRetroSecondViewController 

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 
{ 
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
    if (self) { 
     self.title = NSLocalizedString(@"I Ate Local", @"I Ate Local"); 
     self.tabBarItem.image = [UIImage imageNamed:@"newfood"]; 
     _dataController = [[InSeasonProductDataController alloc] init]; 
    } 
    return self; 
} 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

} 

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

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component { 
    return [_dataController countOfList]; 
} 
- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component { 
    Product *product = [_dataController objectInListAtIndex:row]; 
    return product.name; 
} 

- (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { 

    //do something 
} 



- (void)didReceiveMemoryWarning 
{ 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 

- (void)dealloc{ 
    [_dataController release]; 
    [super dealloc]; 
} 

我得到這個錯誤:

*斷言失敗 - [UITableViewRowData rectForRow:切入口:],/SourceCache/UIKit_Sim/UIKit-2380.17/UITableViewRowData的.m:1630 (LLDB)

+0

你也可以發佈錯誤嗎? – 2013-04-22 02:38:43

+0

我發佈了上面的錯誤 – wwjdm 2013-04-22 02:55:04

回答

2

更改碼本:

- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component { 

if ([_dataController countOfList]>0) { 
    return [_dataController countOfList]; 
}else{ 
    return 1; 
} 

} 

- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component { 
if ([_dataController countOfList]>0) { 
Product *product = [_dataController objectInListAtIndex:row]; 
return product.name; 
}else{ 
    return @""; 
} 
} 
+0

這真的是解決方法。但是,如果沒有數據(空拾取器),選取器會變得非活動狀態會好得多。 – 2013-11-18 16:45:48