Мой вопрос: как отрегулировать большой текст и фиксированный размер изображения в UITableViewCell
.
Мне нужна ячейка autoresize
согласно данным, подобным WhatsApp. Как мне это сделать. Моя ячейка изменяет размер, когда я использую UILabel
, но в случае изображения это испортило все.Авторезистировать ячейку в соответствии с текстом UILabel и изображениями как чат
Пожалуйста, предложите мне. Заранее спасибо.
@ddb это мой исходный код, который я использую.
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return UITableViewAutomaticDimension;
}
-(CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return UITableViewAutomaticDimension;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return [adminDataArray count];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
static NSString *[email protected]"admincell";
adminCell =[tableView dequeueReusableCellWithIdentifier:identifier];
if (adminCell==nil) {
adminCell=[[AdminPostTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
}
adminCell.selectionStyle=UITableViewCellSelectionStyleNone;
[adminCell setBackgroundColor:[UIColor clearColor]];
NSMutableDictionary *getAdminDataDictionary=[adminDataArray objectAtIndex:indexPath.row];
if ([getAdminDataDictionary objectForKey:@"TEXT"])
{
adminCell.lblSenderAdminPage.text=[getAdminDataDictionary objectForKey:@"TEXT"];
adminCell.lblSenderAdminPage.textColor=[UIColor blackColor];
adminCell.lblSenderAdminPage.backgroundColor=[UIColor whiteColor];
adminCell.lblSenderAdminPage.preferredMaxLayoutWidth=305;
adminCell.lblSenderAdminPage.layer.masksToBounds=YES;
adminCell.lblSenderAdminPage.layer.cornerRadius=5;
adminCell.lblSenderAdminPage.layer.borderWidth=1.0f;
adminCell.lblSenderAdminPage.layer.borderColor=[UIColor blackColor].CGColor;
}
else if ([getAdminDataDictionary objectForKey:@"IMAGE"]){
adminCell.imgSenderAdminPage.image=[getAdminDataDictionary objectForKey:@"IMAGE"];
}
return adminCell;
}
доли текущий исходный код, пожалуйста – ddb
Попробуйте эту ссылку http://stackoverflow.com/a/14841373/4970453 –