I am looking to find WebView content size to scale data to fit into small size of WebView Frame.
WebView is continuous loading data as getting images from IP Camera so -(void)webViewDidFinishLoad delegate method is not called, otherwise [webview sizeThatFits:CGSizeZero] would give receiver content size.
How to get WebView content size which is continuous loading data ?
Thanks,
See my answer to a similar question. Instead of -webViewDidFinishLoad you should consider calling this using a timer (and checking whether something has been loaded, first).
If the HTML is under your control, you might wanna call it using a JavaScipt onLoad handler that tries to fetch a custom URL that you can intercept in -webView:shouldStartLoadWithRequest:navigationType:.
Related
I am wondering if anyone can offer any advice towards solving this problem.
I am building an app that uses a UIScrollView with paging enabled, with each page corresponding to downloaded and parsed XML data. Part of that XML data is a URL to an image.
Now, it would take forever to load an app that downloads the image for every XML entry and then push it to the respective UIScrollView page created on runtime with the rest of the XML data.
Is there a way to be able to detect which UIScrollView page you are on and then download the image as needed and still allow the rest of the data to download at runtime?
Try to read SDWebImage or Apple's LazyTableImages
Just as referenece, I solved it by adding all of the image views into an NSArray. Using the scroll view delegate, I was able to determine which page number I was on, and translated that page number to an integer that I used to access the appropriate uiimage view located within the array.
It seems to work great!
Might you offer a better solution?
I am displaying graph by capturing image and loading into a webView using loadHTMLString method.
The images come fine when displayed the first time. But it does not seem to change when I recapture the image which is different.
Also I have checked that the image name is same and the new image is recaptured every time.
It seems to be some issue with UIWebView reloading.
what could be wrong ?
If the same image with the same name is being captured, it may be cached in the UIWebView, causing it to display as the initial image instead of the updated images. If there's a way to use the reload function of the webview (which, in a browser will often check for updates to images), this might help.
If that doesn't solve it, I'd make sure that you're not somehow saving and appending the captured HTML to a variable, causing the new text to be appended to the end of the variable and not loaded.
I get a page full of info from the server VIA JSON. There is a lot of info and different parts to the info, images, text, graphs etc. So i display it inside a UIScrollView so the whole page can scroll. I get some HTMl which i want to display inside a UIWebView. I have the HTML before i create the UIWebView so i can change the height of the UIWebView to contain all the text without the UIWebView itself needing to scroll. But it can vary in length each time i get a new load of data back from the server so i cant hardcore the height it needs to be.
So my question is. Given you have an NSString holding the HTML. Is there a way to calculate how high the UIWebViews frame needs to be, to contain all the HTML without having to scroll.
Hope you understand my question it is kinda long :)
Thanks,
-Code
If it's ok to resize the webview (and the parent scroll view's contentSize property) after the HTML finishes loading, you can use JavaScript to query the rendered height of the HTML and use that. See iPad - find the true height of a UIWebView
Well that would depand on the size of the text in the UIWebView. One way I can think of is to try finding out how many characters (letters) you need to fill one line in your UIWebView. Then use that number to devide your total number of characters in the NSString containing the HTML and base on that number lets call it lanes you could increase the hight of your UIWebView
I'm displaying an MJPEG stream in a UIWebView. I have two different sizes I want to use for the UIWebView. The video size is constant.
So setScalesPageToFit isn't flexible enough, and I have no control over the source to change the viewport meta tag. So I'm left thinking that I need to do this via javascript (of which I have very little knowledge). However I'm stuck with two issues:
1) What javascript to call to change the scale/width of the uiwebview. I've tried variations on:
[webView stringByEvaluatingJavaScriptFromString:#"document.getElementsByTagName('body')[0].style.width='320px'"];
[webView stringByEvaluatingJavaScriptFromString:#"document.getElementsByTagName('body')[0].style.webkitTransform='scale(1.0)'"];
2) I can't stringByEvaluatingJavaScriptFromString from webViewDidFinishLoad, since this doesn't get called when streaming. So I'm calling it straight after my loadRequest.
[edit] I've also now tried calling this a couple seconds later via NSTimer (although i can't really use this approach since I don't know when the video feed arrives). Anyway I see some impact on the scale, but the next frame that arrives seems to reset the scale.
I've recently revisited this and now use a transform on the containing view
how load a pdf into iphone and my pdf is of 200 pages then it should allow to turn the pages as we do with while reading book manually means use animation to turn a page one by one ..
Thanking you ..
Loading a large PDF and having page flipping animation isn't very simple. You can use a UIWebView like #Jim says to load the entire thing by just pointing the UIWebView's URL to the PDF but you won't get page animation. However to get full control requires that you render the PDF page by page manually to a view, and create the view's turning animation your self. Its nontrivial, and given your question you don't sound like you know enough to realistically achieve this right off.
Use UIWebView Control to load pdf files.