My question is how can I adjust the large text and Fixed size of image in UITableViewCell
.
I need the cell to be autoresize
according to data like WhatsApp. How can i do it.
My cell is resizing when I am using the UILabel
but in case of image it messed up everything.
Please suggest me. Thanks in advance.
@ddb this is my source code I am using.
- (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 *identifier=@"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;
}