【发布时间】:2011-07-08 22:43:48
【问题描述】:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)cijferTableView{
return 1;
}
- (NSInteger)cijferTableView:(UITableView *)cijferTableView numberOfRowsInSection:(NSInteger)section {
return [marksArray count];
}
- (UITableViewCell *)cijferTableView:(UITableView *)theTableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [theTableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
}
cell.textLabel.text = [marksArray objectAtIndex:indexPath.row];
return cell;
}
我有一个用字符串填充的标记数组。 该代码在一刻钟前运行良好,但从那以后,当我加载该代码所在的视图时它一直在崩溃,而我没有进行任何更改。
但是,当我在界面生成器中断开数据源时,视图会正确加载而不会崩溃。但当然,在这种情况下它不会填满表格。
我做错了什么?
更新:
控制台给出的错误是在抛出“NSException”实例后调用终止
另外,我还没有在marksArray 中添加任何东西。为了测试,我只有这个:
//.h
NSMutableArray *marksArray;
和
//.m
marksArray = [NSMutableArray arrayWithObjects:@"1", @"2", nil;
【问题讨论】:
-
能否请您发布控制台给您的错误?
-
其实你也可以把初始化marksArray的代码贴出来吗?听起来您可能正在访问一些无效数据。
-
@Jensen2k @Jablair 更新了第一篇文章。
标签: iphone xcode ios4 interface-builder ios-simulator