-1

I try to create image gallery where gallery will have long description like shown image bellow.

enter image description here

The problem is because UIWebView can be any height (depend on text height). So I add UIScrollView so I can scroll if description is higher than page. So how can I set the height of UIWebView and how can I place UIView (with images) that will always be under the UIWebView?

jhilgert00
  • 5,479
  • 2
  • 38
  • 54
ButterBeast
  • 521
  • 10
  • 25

1 Answers1

1

Maybe try setting the size of both the UIWebView and UIView for your gallery from the storyboard Interface Builder. Drag drop and resize each to the height you want.

Say you have a UIView subclass called GalleryView and your IBOutlets are like this:

@property (weak, nonatomic) IBOutlet UIWebView *webView;
@property (weak, nonatomic) IBOutlet GalleryView *galleryView;

Load your webpage

- (void)viewDidLoad
{
[super viewDidLoad];
self.webView.scalesPageToFit = YES; //NO is the default. 
[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://google.com"]]];
}

You'll see the UIWebView is scrollable, so no need to embed it in a scroll view.

Also, there's a warning in the UIWebView reference: "You should not embed UIWebView or UITableView objects in UIScrollView objects. If you do so, unexpected behavior can result because touch events for the two objects can be mixed up and wrongly handled." So, that's that.