iOS Question resizing images in a webview

Discussion in 'iOS Questions' started by Albi, Jun 18, 2015.

  1. Albi

    Albi Active Member Licensed 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!
     

    Attached Files:

  2. narek adonts

    narek adonts Well-Known Member Licensed User

    Sorry but I didn't understood the issue.
    Please explain one more time I will try to help you with my class Zoom Image
     
  3. Albi

    Albi Active Member Licensed 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?!)
     
  4. narek adonts

    narek adonts Well-Known Member Licensed 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
     
  5. Albi

    Albi Active Member Licensed 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!
     

    Attached Files:

  6. narek adonts

    narek adonts Well-Known Member Licensed User

    could you please post an image which is giving error?
     
  7. Albi

    Albi Active Member Licensed User

    importing images from my camera roll gives errors - at the moment, the portrait ones are giving errors.
    no image is shown!
     
  8. narek adonts

    narek adonts Well-Known Member Licensed User

    could you send few of those images please. Because it works fine with all the photos that I have tried
     
  9. Albi

    Albi Active Member Licensed User

    sure, i'll upload some asap
     
  10. Albi

    Albi Active Member Licensed 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!?
     

    Attached Files:

  11. Albi

    Albi Active Member Licensed User

    hello, were you able to have a look at this, as I still haven't been able to get it to work.
    thanks
     
Loading...