0

私のiOSアプリでは、HTMLタグを使用してレンダリングしています

DTAttributedTextView

これはコーディング構造の残りの部分です

//create the custom label to get positions
        UILabel *customLabel = [[UILabel alloc]initWithFrame:CGRectMake(lblContent.frame.origin.x, lblContent.frame.origin.y,lblContent.frame.size.width,lblContent.frame.size.height)];
        customLabel.text = _artistDetail.strContent;
        customLabel.numberOfLines = 0;
        [customLabel sizeToFit];

        [lblContent removeFromSuperview];

        CGRect frame = CGRectMake(customLabel.frame.origin.x, customLabel.frame.origin.y,customLabel.frame.size.width,500);

        NSString *htmlText = HTML_DIV_TAG;
        htmlText = [htmlText stringByAppendingFormat:@"%@%@",_artistDetail.strContent,@"</div>"];
        htmlText = [htmlText stringByReplacingOccurrencesOfString:@"''" withString:@"'"];


        NSData *data = [htmlText dataUsingEncoding:NSUTF8StringEncoding];
        NSAttributedString *string = [[NSAttributedString alloc] initWithHTML:data options:nil documentAttributes:NULL];

        [DTAttributedTextContentView setLayerClass:[CATiledLayer class]];
        DTAttributedTextView  *_textView = [[DTAttributedTextView alloc] initWithFrame:frame];
        _textView.textDelegate = self;
        _textView.attributedString = string;
        [_textView sizeToFit];
        _textView.autoresizesSubviews = YES;
        [self.contentView addSubview:_textView];

今、私はコンテンツの高さに応じてラベルを増やしたいと思っています

4

1 に答える 1

0

次のようなことを試しましたか:

[DTAttributedTextContentView setLayerClass:[CATiledLayer class]];
    DTAttributedTextView  *_textView = [[DTAttributedTextView alloc] initWithFrame:frame];
    _textView.textDelegate = self;
    _textView.attributedString = string;
    CGRect frame = _textView.frame;
    CGSize size = _textView.contentSize;
    frame.size.height = size.height;
    _textView.frame = frame;
    [self.contentView addSubview:_textView];
于 2012-11-28T17:15:34.337 に答える