I’m trying to show TXT file (ASCII) into UIVewView. For example, using the site http://www.partisani.net/35.txt in Safari on MacBook works fine, Safari on iPhone doesn’t. Safari’s iPhone shows the file with another layout. Could someone help me, please?
I’m trying to show TXT file (ASCII) into UIVewView . For example, using the
Share
As far as I can tell, the layout of the file on the Mac vs iOS is exactly the same. Are you talking about text wrapping? You can see that on the Mac by resizing the browser.
If you want to handle the line length differently you’ll need to do so by setting up scrolling.
UPDATE with more detail:
This “sort of” changes the original content :). Basically, you need to tweak both the contentSize of the webview and embed the text file in some boilerplate HTML to reflow the text rather than have the default viewport width assigned to the text document. The latter I accomplish with something like:
The
vw.delegate = selfis important, as you also need to have your controller conform to theUIWebViewDelegateprotocol and implement thewebViewDidFinishLoad:method. There you can set the scroll width and height of your webview as needed:This is an extremely barebones implementation–presumably you would also want logic to calculate the necessary width and height based upon the loaded text rather than use constants as shown here; you’ll need some parsing logic associated with the original data for that, but this should get you started.