1
私は画像のようにダイナミックセルを作成しています。 テーブルビューでダイナミックセルを作成する方法を教えてください。私は単純なコードのデモを行っているどのようにテーブルビューセルでセルの内容に従って動的セルを作成できますか?
コード
self.arrayContainer = [[NSMutableArray alloc]initWithObjects:
[NSDictionary dictionaryWithObjectsAndKeys:
@"H.Rackham",@"name",
@"20/7/1994",@"date",
@"Lorem ipsum dolor sit amet, qui ex blandit posidonium efficiantur, sed te veri bonorum. Per id iriure utroque docendi. Stet patrioque incorrupte ea nam. Prima molestie accommodare nam in, inermis omnesque vix cu. Est posse suavitate eu, ei justo labitur necessitatibus has, no sea agam liber. Deseruisse elaboraret eu ius. Est verterem sententiae an. Prompta elaboraret duo cu, aperiam dolorem has an, ubique nominati comprehensam no pri. In autem scripta concludaturque cum.",@"Description",nil],
[NSDictionary dictionaryWithObjectsAndKeys:
@"Sophia Rhodes",@"name",
@"20/7/1994",@"date",
@" Deseruisse elaboraret eu ius. Est verterem sententiae an. Prompta elaboraret duo cu, aperiam dolorem has an, ubique nominati comprehensam no pri. In autem scripta concludaturque cum.",@"Description",
nil],
nil];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [self.arrayContainer count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *identifier = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
cell.textLabel.text = [[self.arrayContainer objectAtIndex:indexPath.row ]valueForKey:@"name"];
cell.detailTextLabel.text = [[self.arrayContainer objectAtIndex:indexPath.row ]valueForKey:@"date"];
return cell;
}
-(CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 44;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return UITableViewAutomaticDimension;
}
画像
。 今このタイプの機能が必要です。
1)名前と日付は、画像に記載されているように表示が異なります。
2)コンテンツセルに応じてサイズを変更する必要があります。
あなたは
ありがとうございます。私にはお勧めします。どのようにラベルの自動レイアウト制約を設定できますか? – hd1344
@ hd1344 http://stackoverflow.com/questions/12789013/ios-multi-line-uilabel-in-auto-layout –
@ hd1344あなたの問題を解決しましたか? –