Domanda

Come faccio a impostare un interno TTStyledTextLabel di un UITableView. Ogni TTStyledTextLabel contiene Alcuni analizzata HTML.

Ecco quello che ho mi rendo conto suo probabilmente completamente sbagliato.

TTStyledTextLabel* label = [[TTStyledTextLabel alloc] autorelease];
cell.textLabel.text = [TTStyledText textFromXHTML:tempString lineBreaks:YES URLs:YES];

applicazione si blocca su lancio. Penso che sia perché io sono l'impostazione della proprietà .text con qualcosa che non è il testo. Tuttavia, non so che altro per impostare.

È stato utile?

Soluzione

Il seguente codice fare quello che vuoi. Purtroppo, però, non riesco a capire come impostare automaticamente l'altezza. Se la memoria non è un problema si potrebbe tenere una serie separata di TTStyledTextLabels e fa riferimento la loro altezza.

nel loadview:

CGRect cgRct2 = CGRectMake(0, 35, 320, 375); //define size and position of view 
    tblView = [[UITableView alloc] initWithFrame:cgRct2 style:UITableViewStylePlain];
    tblView.dataSource = [self constructDataSource];
    tblView.delegate = self;
    //[tblView reloadData];
    [myView addSubview:tblView];

nella classe:

-(TTListDataSource *)constructDataSource {
    NSLog(@"constructDataSource");
    NSMutableArray * namesArray = [[NSMutableArray alloc] init];

    //ADD ITEMS
    [namesArray addObject:[TTStyledText textFromXHTML:[NSString stringWithString:@"some XHTML"]]];




    TTListDataSource * dataSource = [[TTListDataSource alloc] init];
    for (int i = 0; i < [namesArray count]; i++) {
        TTStyledText * text = [namesArray objectAtIndex:i];

        [dataSource.items addObject:[TTTableStyledTextItem itemWithText:text]];
    }

    [namesArray release];
    return dataSource;
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top