2

I'm trying to make 1 page view to load and image from certain link, I've manage to do that, but the picture didn't fit all the view, I'm planning it to cover the whole view, but it only cover around 80% of it, which mean it still floating in the left side. Is there any code or attribute I need to define to make the page being stretch to fit the whole view?

Thanx in advance.

6
  • 1
    Why not use an UIImageView instead? Commented May 18, 2011 at 8:19
  • 2
    because I was ask to do it in webview.. Commented May 18, 2011 at 9:58
  • How do you load the image? Just set the URL on the UIWebView, or load a HTML from server? Or wrap in your own HTML? Commented May 18, 2011 at 10:31
  • By setting the URL on the UIWebView. Commented May 19, 2011 at 0:30
  • @Viken Ong Have you tried setting the UIWebView's property scalesPageToFit = YES? Commented May 19, 2011 at 7:02

2 Answers 2

2

i think the right approach to this would be adding some css-style to your image (if you can manipulate your html) so that you can control its size and placement...

EDIT: if you set your UIWebView to directly load an image, you could try (I don't know if it is acceptable for you) to wrap the image in a HTML snippet like this:

<html><head>...</head><body><img src=YOU_URL_HERE /><body></html>

so that you can control its size and position through CSS...

Sign up to request clarification or add additional context in comments.

3 Comments

is there any other way than using CSS? Like using a function from the UIWebVieW?
what are the exact image dimensions? are you setting webView.scalesPageToFit = YES? if so, have you tried to set that to NO? see also my edit above...
Since the webview.scalesPageToFit didn't show what I want, your way work better, since it give me more control on the design.. Thanx man..
0

You could set a custom meta viewport for your site.

iPhone viewport dimensions
The viewport is the rectangle area that determines how content is laid out and where text wraps on a webpage. On the desktop, the viewport is determined by the size of the window. The user resizes the viewport by resizing the window and scrolls to see more of the webpage. Safari on iPhone doesn't have windows — there are no scroll bars or resize knobs. Therefore, the "window" is a fixed size determined by the iPhone screen size. The user pans to see more of the webpage, and can also zoom in and out using double tap or the pinch gesture. To make this work on iPhone, the viewport has a scale and width property. When Safari first loads a webpage, it sets the initial scale to fit the webpage completely width-wise on the iPhone screen. [...]

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.