2015-12-15 3 views
0

Когда нагрузка Дейты это показывает идеальный Ограничить-х и данные прекрасно показано с идеальным расстоянием ...Пользовательские ячейки изменения размера Выпуск

Пожалуйста, имеют вид к приспособлению, когда таблица полезной нагрузки:

enter image description here

Когда мы имеем меньше название, то это шоу расстояние:

enter image description here

Я загружая д ата из файлов:

код выглядит следующим образом-х:

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 

    Customviewcell *cell=[tableView dequeueReusableCellWithIdentifier:@"cell"]; 
    UIImage * image = [UIImage imageNamed:justThumbs[indexPath.row]]; 
    cell.Customimage.image=image; 

    cell.CustomTitle.text=justTitles[indexPath.row]; 
    [cell.CustomTitle sizeToFit]; 


    NSString * htmlString =justDesc[indexPath.row]; 
    NSAttributedString * attrStr = [[NSAttributedString alloc] initWithData:[htmlString dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil]; 
    cell.CustomDes.attributedText=attrStr; 

    [cell.CustomDes sizeToFit]; 
    [cell setNeedsDisplay]; 
    [cell layoutIfNeeded]; 
    return cell; 
} 

Загрузка данных из файла, как последующие годы:

-(void)viewDidAppear:(BOOL)animated 
{ 
    [super viewDidAppear:animated]; 
    [tableviewcustom reloadData]; 
} 
- (void)viewDidLoad { 
    [super viewDidLoad]; 
    NSURL * url = [[NSBundle mainBundle]URLForResource:@"services" withExtension:@"plist"]; 
    Servicestitle = [NSDictionary dictionaryWithContentsOfURL:url]; 
    justTitles = [Servicestitle objectForKey:@"Title"]; 
    justThumbs= [Servicestitle objectForKey:@"Thumbnail"]; 
    justDesc=[Servicestitle objectForKey:@"Description"]; 

    tableviewcustom.estimatedRowHeight = 150; 
    tableviewcustom.rowHeight = UITableViewAutomaticDimension; 
    [tableviewcustom reloadData]; 


    // Do any additional setup after loading the view, typically from a nib. 
} 

Раскадровка как последуйте'S:

enter image description here

CustomDes Constrain'S: enter image description here

Добавление фона к названию и алфавиту:

enter image description here

первых 3 клетки:

enter image description here

после того, как первые три ячейки:

enter image description here

Спасибо за помощь.

+0

Привет Talha Аслам ... На мой взгляд, Нужно ли отнести пользователя текст? –

+0

Если вы не используете атрибутный текст, просто удалите следующую строку. ----- cell.CustomDes.attributedText = attrStr ----- и write ---- cell.CustomDes.text = attrStr. –

+0

@JAGAT да, потому что это html и разбор html –

ответ

0

Вы можете использовать метод этого Tableview делегата:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath 

https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITableViewDelegate_Protocol/#//apple_ref/occ/intfm/UITableViewDelegate/tableView:heightForRowAtIndexPath:

+0

Я использую пользовательские изменения размера IOS 8. –

 Смежные вопросы

  • Нет связанных вопросов^_^