私はTableViewCellを持ち、Webサービス(JSON)でデータをロードします。データは異なる配列に格納され、データはtableviewにロードされます。私は、データサイズをある程度大きく、時間を小さく並べる必要があります。ラベルサイズをどのように管理するのか。私は例を試みたが、ダイナミックラベルを作っていない。助けてください、ありがとう。UITableViewCellで動的ラベルサイズを設定する方法
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [title count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
//NSLog(@"tableview cell");
TableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"event"];
if (cell==nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"Cell" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
NSData* imageData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString: [img objectAtIndex:indexPath.row]]];
UIImage* image = [[UIImage alloc] initWithData:imageData];
cell.img.image =image;
cell.lbl_1.text=[NSString stringWithFormat:@"%@",[title objectAtIndex:indexPath.row]];
cell.lbl_2.text=[NSString stringWithFormat:@"%@",[des objectAtIndex:indexPath.row]];
cell.lbl_3.text=[NSString stringWithFormat:@"%@",[evnt_ary objectAtIndex:indexPath.row]];
return cell;
}
重複 - http://stackoverflow.com/q/13190425/3515115 –
http://www.appcoda.com/self-sizing-cells/ –
@balkaransinghお待ちください私はこのリンクを参照してください –