Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9137227
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:04:34+00:00 2026-06-17T09:04:34+00:00

I am trying to put a web view below an image in a scrollview.

  • 0

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?

- (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];
}

from the .h

@interface DetailViewController : UIViewController <UIScrollViewDelegate>{
    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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T09:04:34+00:00Added an answer on June 17, 2026 at 9:04 am

    you are losing the original references to your ivar by reinitializing these values and you are not setting a frame so their height values are 0 which is why your scrollview isn’t getting any larger:

    self.webView = [[UIWebView alloc] init];
    self.imageView = [[UIImageView alloc] init];
    

    try changing them to only initialize if the value is nil

    if(self.webView == nil){
        self.webView = [[UIWebView alloc] init];
    }
    if(self.imageView == nil){
        self.imageView = [[UIImageView alloc] init];
    
    }
    
    //set frames for subviews
    UIImage *remoteLoadedImage = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[self.detailItem imageURL]]];
    [[self.imageView setFrame:CGRectMake(0,0,remoteLoadedImage.size.width, remoteLoadedImage.size.height)];
    [self.imageView.image = remoteLoadedImage];
    //i'm setting an arbitrary height and width
    [self.webView setFrame:CGRectMake(0,self.imageView.frame.size.height+5, 320, 450)];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to search for this on the web, but I'm not sure what
I'm trying to put together (what I thought was) a simple ASP.NET web application
I'm trying to put together a contract-first web application using Spring-WS. I want to
I am trying to put information available on the web, and to do so
I'm trying to put together a real simple MVC DataBind sample. I'm comparing Telerik
I'm trying put an if statement directly into a select field in rails, with
Trying to put a regex expression together that returns the string between _ and
I trying to put together an Android app that will take a picture and
I'm trying to put together a script to monitor the MSMQ on a server.
So I am trying to put two inline dropdown lists. I tested and it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.