Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to set height dynamically of a uitextview
    primarykey
    data
    text
    <p>I want to set height dynamically on my UITextView, but it doesn't works. My code is :</p> <pre><code> [super viewDidLoad]; DTAttributedTextView *_textView; contentView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, self.view.frame.size.height)]; _textView = [[DTAttributedTextView alloc] initWithFrame:CGRectMake(0.0, 80.0, self.view.frame.size.width, self.view.frame.size.height)]; UIImage *backgroundImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://www.epnet.fr%@",[[[currentDicoNew valueForKey:@"image"] valueForKey:@"thumb_rect"] valueForKey:@"url"]]]]]; imageNew = [[UIImageView alloc] initWithFrame:CGRectMake(0, 40, 320, 178)]; imageNew.image = backgroundImage; imageNew.contentMode = UIViewContentModeScaleAspectFill; CGSize maxImageSize = CGSizeMake(self.view.bounds.size.width - 20.0, self.view.bounds.size.height); NSString *html = [SundownWrapper convertMarkdownString:[currentDicoNew valueForKey:@"content"]]; NSData *HTMLData = [html dataUsingEncoding:NSUTF8StringEncoding]; NSDictionary *options = @{ DTDefaultFontFamily : @"Helvetica", DTDefaultFontSize : [NSNumber numberWithFloat:14.0], DTDefaultLinkColor:[UIColor colorWithRed:0.0/255.0 green:174.0/255.0 blue:239.0/255.0 alpha:1], DTMaxImageSize : [NSValue valueWithCGSize:maxImageSize], }; NSAttributedString *attrString = [[NSAttributedString alloc] initWithHTMLData:HTMLData options:options documentAttributes:nil]; _textView.attributedString = attrString; _textView.shouldDrawImages = YES; _textView.shouldDrawLinks = YES; _textView.textDelegate = self; [_textView setScrollIndicatorInsets:UIEdgeInsetsMake(0, 0, 44, 0)]; _textView.contentInset = UIEdgeInsetsMake(10, 10, 54, 10); [_textView.attributedTextContentView setNeedsDisplay]; [_textView setScrollEnabled:NO]; [contentView addSubview:_textView]; MDCParallaxView *parallaxView = [[MDCParallaxView alloc] initWithBackgroundView:imageNew foregroundView:contentView]; parallaxView.frame = CGRectMake(0, 40, 320, self.view.frame.size.height); parallaxView.backgroundHeight = 100; parallaxView.scrollView.scrollsToTop = YES; parallaxView.backgroundInteractionEnabled = YES; parallaxView.scrollViewDelegate = self; [self.view addSubview:parallaxView]; </code></pre> <p>the height is equals to 420 (self.view.frame.size.height) but, I want to know how to retrieve the height of the dynamic content. Because, when I code this in the viewDidDisapear, it works but not in the ViewDidLoad:</p> <pre><code>CGRect frame1; frame1 = _textView.frame; frame1.size.height = [_textView contentSize].height; _textView.frame = frame1; NSLog(@"%f", frame1.size.height); </code></pre> <p>So, how I can set the height dynamically, please ? Many thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload