我有一个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