我有一個帶有字典值數組的可用視圖,該數組產生一個相當大的列表。 用戶可以從中進行選擇..一旦用戶選擇一個單元格,我從導航堆棧中彈出視圖,並將所有值傳回主視圖。然後,如果用戶已經創建了該視圖,則允許用戶返回此視圖一個錯誤,並想改變他們的意見。由於UITableViewScrollPositionMiddle在手機上測試但不是仿真器時,應用程序崩潰
當他們點擊回該視圖我有一種方法,使用UITableViewScrollPositionMiddle自動滾動到舊選定的視圖。
但是我認爲它在手機上使用時會導致一些錯誤,因爲模擬器工作正常。
這裏是我認爲錯誤是發生
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
//Center previously selected cell to center of the screen
[self.tableView scrollToRowAtIndexPath:oldCheckedData atScrollPosition:UITableViewScrollPositionMiddle animated:YES]; //<--- this method
}
,這是它建立到我的電話,當我在日誌中得到錯誤。爲了得到這個錯誤的過程是讓用戶點擊加載子視圖的父視圖中的單元格,用戶在子視圖中選擇一個單元格並將其帶回父視圖。然後,當用戶返回時到日誌中顯示的相同子視圖。
2011-10-19 15:00:05.790 icode[1564:707] -[__NSArrayM section]: unrecognized selector sent to instance 0x181cd0
2011-10-19 15:00:05.797 icode[1564:707] CoreAnimation: ignoring exception: -[__NSArrayM section]: unrecognized selector sent to instance 0x181cd0
(沒有滾動效果) 然後用戶選擇不同的小區和該應用崩潰,這表明了該日誌
2011-10-19 15:01:08.272 icode[1564:707] -[__NSArrayM row]: unrecognized selector sent to instance 0x181cd0
2011-10-19 15:01:08.275 icode[1564:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayM row]: unrecognized selector sent to instance 0x181cd0'
*** First throw call stack:
(0x35e9e8b3 0x366e61e5 0x35ea1acb 0x35ea0939 0x35dfb680 0x334a76cf 0x3353c713 0x30e1d 0x3352cd69 0x335a60ab 0x35cc32ab 0x35e72a57 0x35e726bd 0x35e71293 0x35df44e5 0x35df43ad 0x30fa4fed 0x334a7dc7 0x24f7 0x24a0)
terminate called throwing an exception(gdb)
任何幫助,將不勝感激英寸
泰伯維數據源
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return [arraysByLetter count];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
NSString *currentLetter = [sectionLetters objectAtIndex:section];
return [[arraysByLetter objectForKey:currentLetter] count];
}
/*
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
//override state-based properties set earlier by the table view, such as selection and background colorset up shit here
}
*/
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
//Customize cell here
cell.selectionStyle = UITableViewCellSelectionStyleNone; // no blue selection
//Replaces previously selected cells accessory view (tick)
if (indexPath == oldCheckedData)
{
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
else
{
cell.accessoryType = UITableViewCellAccessoryNone;
}
//Display cells with data
NSArray *keys = [self.arraysByLetter objectForKey:[self.sectionLetters objectAtIndex:indexPath.section]];
NSString *key = [keys objectAtIndex:indexPath.row];
cell.textLabel.text = key;
return cell;
}
//Section headers
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
return [sectionLetters objectAtIndex:section];
}
//Section header titles
- (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView
{
return sectionLetters;
}
發佈顯示TableViewDataSource方法的代碼。從日誌中,您將行和節的方法傳遞給導致應用程序崩潰的Array對象。編譯源代碼時還要看編譯器警告。 – 0x8badf00d
當它生成時沒有警告..我用模擬器中的TableViewDataSource方法 –