问题
I want to display PDF within iOS application, so far the only way I find is open it in TwebBrowser.
A.It is displaying in "fit to page width" zoom as default
B.There is no "zoom" function
WebBrowser1.Navigate(file://mypdf.pdf')
How to
- I want to change the zoom after open the file (My solution encounter q#2)
- Make the zoom work (My solution encounter q#3)
- Make the gesture as work just like web page
For #1:
I chagne WebBrowser1.height/width in run-time, it will auto scale(zoom?) as "Fit to width".
Yes it works, and vertical scroll bar works with a flaw - it will not bounce back on edge -> you can scroll all the way down..
Neither the horizontal scroll, not reacting at all....
*This is because the pdf is A4, not sure what will happen for a landscape style
For #2:
Beside using button clicks to zoom, I add a gestureManager.
Then add Form1.ongesture just like the "iOS Interactive Gestures - Image Zoom" example.
Yes it works, but same thing - no vertical bounce, no horizontal scroll.
*ScrollBox does not work, it will not work with any thing has a build-in vert/hori scroll bars
For #3 : I go even further, write control for up/down/left/right
Change WebBrowser1.Position.X/Y and WebBrowser1.height/width to make it looks like "scrolling"
Yes it works... but two custom gesture controls are making it really hard to control
(EventInfo.Distance and EventInfo.X/Y, those 2 controls are kinda overlaping to eachother if you run in iPhone)
The wosrt part is, the WebBrowser1 will be on top of ANY compenment, regardless parent/child structure . The second worst part is the limitation of margin is hard to code, somehow it can always scroll over the limit.....
I "feel" if changing the zoom on/after open, and make it open with both vert/hori scrool bars visible. Then the horizontal bar should work -> i only need to deal with zoom -> pretty close to prefect.
Of course the best way is to make it work like a web page, like WebBrowser1.Navigate('http://www.embarcadero.com/') -> both scrollbars works, zoom work. but...maybe need service pack N for this?
I appreciate for any ideas or code answers.
This damned monkey is on fire and its always hard to find an answer from it.
回答1:
An article was posted today on The Hacker's Corner called Getting TWebBrowser on iOS to zoom. It suggests a one-line fix to the FMX.WebBrowser.iOS.pas unit. Does this help?
回答2:
It was a bug, and fixed in the XE4 update.
来源:https://stackoverflow.com/questions/16371768/twebbrowser-zoom-gesture-is-not-working-for-firemonkey-ios-in-xe4-when-open-a-pd