iOS Question resizing images in a webview

Albi

Active Member
Licensed User
Longtime User
Hello,

(Sorry for the all the recent questions!)

To get pinch and zoom with images, I'm using a webview. however, the images don't all resize correctly. I'm using scaletofit. The portrait images are (mostly) ok. The landscape ones are the correct height which makes them too wide.

I've just put a webview into the camera example as an mwe and attached it.
I've tried do some things in the page1_reszie routine, such as setting scaletofit=true again. Not sure what else to try since the view is sized correctly, but the image within it isn't.

I appreciate the landscape pictures don't fit correctly, but the usual whitespace at the top and bottom is fine. That's normal and is what happens if it's an imageview instead of a webview.

(I also tried zoomimages class that was made last night. While it was super easy to use, it has the same issue).

Thanks!
 

Attachments

  • CameraExample.zip
    24.6 KB · Views: 231

Albi

Active Member
Licensed User
Longtime User
That would be great if you could have a look as using your class would be brilliant!
The horizontal image that i either took or imported from the camera roll is bigger than the screen width. I would like it to appear as it does in the camera roll, the the width is the same size as the screen (the height is reduced) and then you can pinch and zoom and scroll while you are zoomed in.

I've attached a couple of screenshots, one of the image how id' want it to appear (although in the centre, rather than at the top), and one how it appears here...
image1.PNG image2.PNG
(also, with your class, I found some images didn't appear at all, and some were located off screen to begin with?!)
 
Upvote 0

narek adonts

Well-Known Member
Licensed User
Longtime User
in Zoom Image class when you do not put the minscale, maxscale it automatically calculate the min scale factor to fit the whole view size. If you want to show the whole image instead you can simply change the scale after. you need to calculate it.
for ex. try zoomimage.minscale=Min(view.Width/Bitmap.Width,view.Height/Bitmap.Height)
or zoomimage.scale=Min(view.Width/Bitmap.Width,view.Height/Bitmap.Height)

Narek
 
Upvote 0

Albi

Active Member
Licensed User
Longtime User
thanks. that helped but it's still not working all the time.
The horizontal images are ok (except the first time when it's the wrong width) but the portrait images aren't appearing at all.
I made a little change and got them to appear but the landscape images stopped appearing! I can't recreate what I did for that though.

I've attached the project above edited to use zoomImage instead of a webview.

Thanks for your help!
 

Attachments

  • CameraExample.zip
    47.3 KB · Views: 243
Upvote 0

Albi

Active Member
Licensed User
Longtime User
importing images from my camera roll gives errors - at the moment, the portrait ones are giving errors.
no image is shown!
 
Upvote 0

Albi

Active Member
Licensed User
Longtime User
hello. I had to reduce the size so I could upload the images. I might have made them a bit small.
And am not sure what the easiest way to get them into your camera roll is!?
 

Attachments

  • pic1.JPG
    pic1.JPG
    28 KB · Views: 222
  • pic2.JPG
    pic2.JPG
    22.2 KB · Views: 223
Upvote 0

Albi

Active Member
Licensed User
Longtime User
hello, were you able to have a look at this, as I still haven't been able to get it to work.
thanks
 
Upvote 0
Top