【发布时间】:2013-11-25 13:15:46
【问题描述】:
开发一个 iPAD 应用程序,我试图在其中填充表格,这就是我正在做的事情: 在视图确实加载时,我正在创建两个字典对象并将对象添加为 Pdf 和 Excel。
- (void)viewDidLoad
{
[super viewDidLoad];
arrDocuments = [[NSMutableArray alloc] init];
NSArray *arr1 = [NSArray arrayWithObjects:@"PDF", nil];
NSDictionary *pdf = [NSDictionary dictionaryWithObjects:arr1 forKeys:nil];
NSArray *arr2 = [NSArray arrayWithObjects:@"Excel", nil];
NSDictionary *excel = [NSDictionary dictionaryWithObjects:arr2 forKeys:nil];
[arrDocuments addObject:pdf];
[arrDocuments addObject:excel];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return [arrDocuments count];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
//return [arrReceipes count];
NSDictionary *dictionary = [arrDocuments objectAtIndex:section];
NSArray *array = [dictionary objectForKey:[self.sortedKeys objectAtIndex:section]];
return [array count];
}
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *MyIdentifier = @"MyIdentifier";
UITableView *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell ==nil) {
cell = [[UITableViewCell alloc]initWithFrame:CGRectZero reuseIdentifier:MyIdentifier];
}
return cell;
}
有了这个实现,我看不到表格视图。它进入主方法并向我显示 SIGABRT 消息。我哪里出错了??
【问题讨论】:
-
在 cellForRowAtIndexPath 添加:cell.textLabel.text = ...
-
您实际上是在哪里创建表格视图的?
-
@llario,智能没有显示“cell.textLable.text”,当我写这个时,它显示的 textLable 没有被识别..
-
发布任何 NSLog in 方法并检查应用程序崩溃的位置..
-
这个 self.sortedkeys 是什么?
标签: ios objective-c ipad uitableview