在我的 tablview 行中显示成功文本后,我没有设法在行中放置标签和一些额外的文本。作为普通字体的文本和更小字体的额外文本。当我执行此代码时,我的设备会在我的数据库中显示 18 行,其中包含“creation_date”的内容。但我想显示每一行的“creation_date”和“名称”。如果我复制并粘贴 cell.textLabel 行并将“creation_date”更改为“名称”,我会得到一个 SIGABRT:8 如果有人可以帮助我吗?这是我的代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *MyIdentifier = @"Cell";
NSString *LBLS = @"go";
NSString *LBLR =@"smogogo";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:MyIdentifier] autorelease];
CGRect frame = CGRectMake(0, 0, 160, 50);
UILabel *lbl1 = [[UILabel alloc] initWithFrame:frame];
lbl1.textAlignment = UITextAlignmentRight;
[lbl1 setFont:[UIFont fontWithName:@"Helvetica" size:12.0]];
[lbl1 setTextColor:[UIColor grayColor]];
int storyIndex = [indexPath indexAtPosition: [indexPath length] - 1];
LBLS = [[stories objectAtIndex:storyIndex] objectForKey: @"module"];
if ([LBLS isEqualToString:dataType]){
lbl1.text = [[stories objectAtIndex: storyIndex] objectForKey: @"creation_date"];
LBLS = [[stories objectAtIndex:storyIndex] objectForKey: @"module"];
if ([LBLS isEqualToString:dataType])
[cell.contentView addSubview:lbl1];
[lbl1 release];}
CGRect frame2 = CGRectMake(0, 0, 250, 50);
UILabel *lbl2 = [[UILabel alloc] initWithFrame:frame2];
lbl2.textAlignment = UITextAlignmentRight;
[lbl2 setFont:[UIFont fontWithName:@"Helvetica" size:12.0]];
[lbl2 setTextColor:[UIColor blackColor]];
lbl2.text = [[stories objectAtIndex: storyIndex] objectForKey: @"name"];
if ([LBLS isEqualToString:dataType]){
[cell.contentView addSubview:lbl2];
[lbl2 release];}
return cell;
}