我有一个带有字典值数组的可用视图,该数组产生一个相当大的列表。 用户可以从中进行选择..一旦用户选择一个单元格,我从导航堆栈中弹出视图,并将所有值传回主视图。然后,如果用户已经创建了该视图,则允许用户返回此视图一个错误,并想改变他们的意见。由于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方法 –