1

I have get some issue regarding Self Sizing Cell in UITableView. i have to use UITableView and cell Style is "Right Details" then use all stuff regarding self sizing code but not work properly self sizing cell and seen github mini project regarding self sizing and use some sample project but issue is not solve, if any one have solution so please provide me. Below code

#import "ViewController.h"

@interface ViewController ()  
{
  NSMutableArray *tableData, *detailData;
}
@end

@implementation ViewController
@synthesize tableView=_tableView;

- (void)viewDidLoad {
[super viewDidLoad];

tableData = [[NSMutableArray alloc] initWithObjects:@"Monday",@"Tuesday",@"Wednesday",@"Friday",@"Saturday",@"Sunday", nil];

detailData = [[NSMutableArray alloc] initWithObjects:@"123456",@"112345612345612345612345612345612345612345612345612345612345612345612345612345612345612345612345612345612345612345612345612345612345612345612345612345612345612345612345612345612345612345612345612345612345612345612345612345612345612345612345612345612345612345612345623456123456123456123456123456123456123456123456123456123456112345612345612345612345612345612345612345612345612345612345612345623456",@"123456",@"123456",@"123456",@"123456", nil];

_tableView.estimatedRowHeight = 68.0;
_tableView.rowHeight = UITableViewAutomaticDimension;

}

#pragma mark - Table view data source

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

return tableData.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *simpleTableIdentifier = @"cell";

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];

if (cell == nil) {
    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}

cell.textLabel.text = [tableData objectAtIndex:indexPath.row];
cell.detailTextLabel.text = [detailData objectAtIndex:indexPath.row];
cell.textLabel.numberOfLines = 0;
cell.detailTextLabel.numberOfLines = 0;

return cell;

}

i have to use this code but the details label not self size, when change the UITableView Style with Basic Cell and Custom Cell,that is work perfect. But i need only Right Details Style UITableView. Thanks in advance.

Ashwani Sharma
  • 59
  • 1
  • 11

0 Answers0