WKWebView dynamic sizing issues - ios

In an app I am currently working on, UIWebView is used to display files such as PowerPoints and such. There is a drawer to the right of the web view that can be opened and closed via a UIPanGestureRecognizer. As you resize, then open or close, a black artifact will appear on the right side of the web view, exactly as seen on this question: Black bar appearing in UIWebview when device orientation changes.
Between that issue, and the issue in iOS 8 with PDFs rendering with a black background, I decided to try out WKWebView. That doesn't have either issue, however when the web view's width changes dynamically (the right constraint is bound to the pan gesture) the content in the web view is very slow. The web view either doesn't resize, or is very choppy/blocky as it does. This issue isn't present when using UIWebView. Does anyone have either any pointers to fix the issue with UIWebView and that black artifact, or why WKWebView is performing so badly?

re: the WKWebView
My guess is that the webview is attempting to re-render its contents several times as the frame is adjusted. This could cause the choppiness, and there may not be much you can do about that. (not sure)
One way you could 'cheat' is by taking a snapshot of the webview before adjusting its frame, and laying it over top of the webview.
set the webview's hidden property to YES in hopes of killing the re-rendering as the frame is adjusted.
hook up the snapshot to the pan gesture recognizer, and when the gesture ends, give the webview its final frame and set hidden back to NO
at this point, you can remove the snapshot (maybe with an alpha animation) and the webview should only ever have to re-render its content once.
there will probably be a disparity between the snapshot's appearance and the webview's final appearance, but it should be workable.

Related

On orientation change touch events recognized for half the screen(portrait width)

I have a PageViewController which handles the gestures so I have not done anything with it. I disabled auto-layout in my storyboard so that I could use autoresize to fill the screen with views.
I have a tabbar and if I reload the page with the tabbaritem. The gesture are working.
How can I make the touch/gesture handler resize on orientation change?
http://kevindew.me/post/18579273258/where-to-progmatically-lay-out-views-in-ios-5-and
In the above link you will find usefull information about laying out and handling orientation changes. Also I had this problem once on a device with lower iOS version if your version can be updated you can try that however it's not a fix. I recommend to check the link and see if your views are properly layed out.

MWPhotoBrowser - Images moving inside view

I am sure this is an easy question, but I am lost. I have MWPhotoBrowser and a bunch of photos loaded into the browser. Everything works beautifully, except if I click on an image in the browser and drag it around the screen it moves everywhere and repositions the image. Essentially I just want to stop if from dragging around all together.
Any recommendations ?
There were two issues causing this problem:
Autolayout was turned off. Since I wanted it to remain off I had to create a work around with #2.
The content appears to be sized to the View. In my case the view height was much larger than the available display area on the screen. To work around the issue I used another view sized to the viewable area and added the browser to that view rather than the super view.

IOS - How to get my text view object information to scroll on view?

I am using Mac OS X Lion 10.7.5 and XCode Version 4.6.1 (4H512),
I have looked at these answers on stackoverflow to try to figure out my question
-cannot make a text view scroll - xcode 4.3
-also posts that looked possible, when I searched on "scroll text in UITextView" within stackoverflow
Within Interface Builder I cannot figure out how to make information in a UiTextView object scroll within the iPhone simulator*. To resolve this challenge, I have made the most simple prototype project I can think of, just a view and one text view object on it, filling the text view object with a stream of text simply typed in via interface builder. For this most basic sample I'm using to sort out my problem, I have not done anything programatic. (Please note that I am aware of StoryBoards and have begun working through a book to learn to use them, but I would like to finish my first prototype app using what I’ve already learned and fully complete one project before I move onto my next project using StoryBoards.)
When I run this in the iPhone simulator, I see the sample information in my text view object come up. As I expected not all the information displays, due to my sizing the box a little too small on purpose. But I cannot flick or arrow down, or in any other way view the rest of the text information within the simulator. Nor do I see scrolling bars anywhere on the view. The information is just frozen in/on the view.
Inspector Settings
Identity Inspector
"Accessibility" Tested both with Enabled checked and not checked
Use Auto Layout is NOT checked
Attributes Inspector
Behavior Editable box not checked
Scroll View Area Checked ‘show horizontal scrollers, shows vertical scrollers and also scrolling enabled” The rest of the scrollers box are not checked
Bounces is checked
Zoom min and max are both 1
Touch all boxes checked- bounces zoom, delays content touches, cancellable content touches
View mode is ‘scale to fill”
Interaction ‘multiple touch’ is checked
Drawing checked opaque, clears graphics context, clip subviews, and autoresize subviews. Only ‘hidden’ is not checked
Size Inspector
I played around with the ‘scrolling insets’ boxes changing them from the default (I think it was 0 or 1), just to see if I noticed anything. I think maybe that I see some shadowy marker type lines in Interface builder in the area where I might expect a scroll bar when I make these changes, but no change in appearance within the simulator.
I cannot figure out why my actual iPhone device with everything up to date, is now not working as a test device, but I believe that is a separate challenge
how about wrapping you uitextfield in a uiscrollview. Make the scroll view the dimensions you currently are setting the uitextfield to, then allow your uitextfield to scale to the size of the text.
This is one of those questions that solved itself eventually. After twice creating the most basic app, with no programmatic bits just interface builder and a textView object with all the defaults the scrolling worked. The only reason I can think of that it might not have scrolled as expected the first time through may have had to do with placement of the textView object on the view. I wonder if it overlapped the bottom of the view and maybe that messes something up.
Just one of those situations where I had to keep plugging away, trying what seemed like the same thing repeatedly,set in the Inspectors, and suddenly, like magic, it worked. Except no magic involved.

Zooming and UIWebView

I am having a problem with UIWebView. My application displays pdfs from local memory and displays them in a webView in fullscreen mode. By default, when the page loads, the content is apparently set to fit horizontally, which cuts off some of the bottom of the pdf. I would like it to initially show up vertically fit and horizontally centered. I have looked for an answer to this question for quit some time and can't seem to find anything.
Any ideas?
(Please do not suggest scalesPageToFit. Although it fixes many beginning problems, this is not one of them.)
uiWebView.scrollView property has the ability to set zoom and also manage display of content
UIScollView class ref

Artifacts after orientation change

My app consists of 2 screen (main and settings) both are filled with scrollview completely. Each has one view controller and is supposed to support landscape and portrait orientations. I'm using Autosizing to achieve that and it works fairly well (all elements are where they should be, size is also correct) but I'm getting strange artifacts when the screen is rotated e.g. picker frame remains the same when the actual "drum" area inside is resized properly, text field is partially overlapped by background, landscape graph remains in place and is overlapped by portrait graph.
All are just basic elements without modifications, there are no images or anything special (graph is exception, I'm reloading it in didRotateFromInterfaceOrientation:). Any ideas why would that happen, why aren't the basic elements redrawn properly?
Figured it out myself in the end. Had to implement workaround as iOS apparently can't do it itself.
1) Artefacts after automatic view resize. Solution here was to hide the view before changing orientation, reload the graph and show it again after orientation was changed. Doesn't look perfect but much better than before.
2) Other problems were caused by the pickerview. Autoresize apparently doesn't work at all. The solution here was create UIView instead of the picker which resizes without problem and again recreate the pickerview every time the orientation changes.

Resources