我有一個TableView建立並繪製好,但然後在滾動視圖崩潰。我已經運行了調試器,看起來我的類級別的變量正在被覆蓋,所以當再次調用titleForHeaderInSection時,它們不再存在。非常奇怪的是,如果我替換代碼:UITableView在滾動崩潰
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
NSString *sectionTitle = [favouritesDataSections objectAtIndex:section];
return sectionTitle;
}
有:
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
NSString *sectionTitle = @"Test";
return sectionTitle;
}
它仍然崩潰,但這次調試器列表中沒有一個NSString當你將鼠標懸停在sectionTitle變量。
這是我用來創建視圖的代碼,並設置類級別的變量:
- (void)loadView {
[super loadView];
CGRect tableSize = CGRectMake(0,0,320,460);
UITableView *favouritesTableView = [[UITableView alloc] initWithFrame:tableSize style:UITableViewStylePlain];
favouritesTableView.autoresizingMask = (UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight);
favouritesTableView.dataSource = self;
favouritesTableView.delegate = self;
favouritesTableView.rowHeight = 52;
[self.view addSubview:favouritesTableView];
}
- (void)viewDidLoad {
[super viewDidLoad];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
// Get the full path of the favourites plist
NSString *filename = [documentsDirectory stringByAppendingPathComponent:@"Favourites.plist"];
// Initialise Dictionary and array
favouritesDataAll = [[NSMutableDictionary alloc] init];
favouritesDataSections = [[NSArray alloc] init];
NSDictionary *dict = [[[NSMutableDictionary alloc] initWithContentsOfFile:filename] retain];
favouritesDataAll = dict;
[dict release];
favouritesDataSections = [favouritesDataAll allKeys];
}
我會絕對瘋狂試圖跟蹤下來 - 了2天就可以了到目前爲止,一切會對外感謝任何幫助。
問候
戴夫
OK,如果我把在在的UITableView行它適用於約3或四次到底保留,然後控制檯提供: *** - [UISwipeGestureRecognizer長]:無法識別的選擇發送到實例0x43325d0 – 2009-11-29 08:30:13
和還有: ***由於未捕獲的異常「NSRangeException」而終止應用,原因:'*** - [NSCFArray objectAtIndex:]:index(0)beyond bounds(0)' – 2009-11-29 08:35:37
好的,我會閉嘴的。我認爲保留是我的紅鯡魚。這是因爲我將titleForHeaderInSection替換爲@「Test」,它已經工作了一段時間。控制檯錯誤是: ***終止應用程序由於未捕獲的異常'NSRangeException',原因:'*** - [NSCFArray objectAtIndex:]:索引(57744)超出界限(2)' – 2009-11-29 08:39:51