Note that there are some explanatory texts on larger screens.

plurals
  1. POadding content to UIScrollView
    text
    copied!<p>I am trying to put a web view below an image in a scrollview. This code leads to a blank screen. I'm sure it's extremely simple (I'm a beginner), but could someone point me to my mistake?</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; self.title = [self.detailItem title]; //self.webView = [[UIWebView alloc] init]; //self.imageView = [[UIImageView alloc] init]; UIImage* image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[self.detailItem imageURL]]]]; self.imageView.image = image; [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[self.detailItem url]]]]; [self.scrollView addSubview:self.imageView]; [self.scrollView addSubview:self.webView]; self.imageView.frame = CGRectMake(0, 770, 320, 230); [self.webView setFrame:CGRectMake(0, 0, 320, 770)]; CGFloat scrollViewHeight = 1000.0f; /* for (UIView* view in scrollView.subviews) { NSLog(@"%f",view.frame.size.height); scrollViewHeight += view.frame.size.height; } */ [scrollView setContentSize:(CGSizeMake(320, scrollViewHeight))]; NSLog(@"%f", self.imageView.frame.size.height); NSLog(@"%f", self.webView.frame.size.height); [self configureView]; } </code></pre> <p>from the .h</p> <pre><code>@interface DetailViewController : UIViewController &lt;UIScrollViewDelegate&gt;{ UIScrollView* scrollView; } @property (nonatomic, retain) IBOutlet UIScrollView *scrollView; @property (strong, nonatomic) id detailItem; @property (nonatomic, strong) UIWebView *webView; @property (weak, nonatomic) IBOutlet UILabel *detailDescriptionLabel; @property (nonatomic, strong) UIImageView *imageView; @end </code></pre>
 

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