Pinch zoom on iOS HTML Viewer

Thanks, Michel! Scale is indeed a method scaling the CGAffineTransform that’s currently applied to the view. You can create a new transform from scratch by using the setScale method. (And if you have a better idea for the name – I know it can be misleading –, please let me know! The current naming scheme is an analogy to the Rotate / SetRotation etc. methods.)

EDIT: I know the Wiki is still missing a lot of things and it does not reflect the recent change in general naming conventions. But you can find information on these methods and properties in the iOSLibView (AppleView) class Wiki page. And for easy effects there are a lot of GPU-based animation methods included.

[quote=192595:@Ulrich Bogun]Thanks, Michel! Scale is indeed a method scaling the CGAffineTransform that’s currently applied to the view. You can create a new transform from scratch by using the setScale method. (And if you have a better idea for the name – I know it can be misleading –, please let me know! The current naming scheme is an analogy to the Rotate / SetRotation etc. methods.)

EDIT: I know the Wiki is still missing a lot of things and it does not reflect the recent change in general naming conventions. But you can find information on these methods and properties in the iOSLibView (AppleView) class Wiki page. And for easy effects there are a lot of GPU-based animation methods included.[/quote]

Congratulations. This is a very thorough implementation.

I am still a bit puzzled. The wiki mentions ScaleToFit which is necessary to enable pinch to zoom, but it is not implemented as such. You may have forgotten to expose it. Or is it Viewer.ScalesPageToFit the Scale button ? Pinch to zoom does not seem to have any effect, unlike in Safari on my iPhone 5. Could it be the Simulator ? Or is there something else ? The test is on http://fontmenu.com/xojo/xmetro.pdf

You may want to stick to Apple methods and property names, so users could refer directly to the Apple Mac Developer Library page. I would also tend to make all properties visible in the Inspector behavior. That may make things easier for development than having to do everything in code.

Correction : pinch zoom does work with Viewer.ScalesPageToFit. What I did not get was that when using option-click in the simulator, I needed to make sure the dots were both on the control (duh). And it works on both pictures, PDF and web sites. So indeed this is the solution for the OP :slight_smile:

Glad to read that! I was just about to write I probably haven’t implemented the pinch gesture … :wink:
I believe there’s still a few methods and properties missing on that control. I’ll add them for the next release.

EDIT: Yes, I haven’t done much work on convenience methods handling Xojo types and classes for this control, as well as inspector properties. Will follow too.

Thanks again for having a look into this class, Michel! I have added the missing properties and methods to the AppleWebView class (but not to the custom controls and no convenience methods yet) and pray that SourceCode is in good mood today.

Great. Thank you Ulrich. It is good to have such a resource.

[quote=192360:@Jason King]Try (untested but it is the declare for the property you mentioned):

Declare sub setScalesPageToFit lib "UIKit" selector "setScalesPageToFit:" (obj_id as ptr, yesNo as boolean) SetScalesPageToFit(HTMLViewer1.handle, true)[/quote]

I was not usable after it became 2018 Release 2.
Please tell me the new method.

This was brought to my attention by another forum user. The change from UIWebView to the WK equivalent broke all of the iOSHTMLViewer declares I had put together. For now use 2018r1.1, I’m working on a fix and should have it within a week.

Untested

Declare sub allowsMagnification lib "UIKit.framework" selector "setAllowsMagnification:" (obj_id as ptr, value as Boolean) allowsMagnification(htmlViewer1.handle, true)

Unfortunately the setAllowsMagnification code, above, doesn’t work. And according to this, WKWebView zooming is to be handled by the underlying UIScrollView.

How can we do this with Xojo?

I use this in my iOS apps:

HTMLViewer1.ExecuteJavaScript(“document.body.style.zoom=”“150%”"")

This has been working for a long time, but since the last iOS update, the app is crashing down without any message.

iOSHTMLViewer has no ExecuteJavascript function.

Is that an “extends” function you have in a module?

EDIT: when an app crashes in the simulator without any message, a crash report with the name of your app is saved to ~/Library/Logs/DiagnosticReports

iOSHTMLViewer has now a variable zoom feature. Now I use this instead of JavaScript.