tablview 行に成功テキストを表示した後、ラベルと余分なテキストを行に入れることができませんでした。通常のフォントのテキストと細いフォントの追加テキストとして。このコードを実行すると、データベースに「creation_date」が含まれる 18 行がデバイスに表示されます。しかし、各行の「作成日」と「名前」を表示したい。cell.textLabel 行をコピーして貼り付け、「creation_date」を「name」に変更すると、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;
}