TableViewCell을 사용하고 웹 서비스 (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 잠시만 기다려주세요.이 링크가 보입니다. –