0
votes

I'm having some problems with the zoomscale on my scrollview in landscape mode. I want my image to scale perfectly when i put my iphone in landscape. I have the zoomscale on my scrollview working fine when i'm loading my image in portrait mode, but when i put it to landscape, it wont change the scale, unless I go back to the tableview and put the iphone in landscape, and then load the image.

Any help apriciated!

I've tried using such as:

if (UIDeviceOrientationIsLandscape(UIDevice .currentDevice().orientation))
    {
        scrollView.zoomScale = 0.50
    }


    if (UIDeviceOrientationIsPortrait(UIDevice .currentDevice().orientation))
    {
        scrollView.zoomScale = 0.25

    }

This is how it looks like when I load the image in portrait mode:

This is how

This is how it looks like when i rotate the iphone from portrait mode while having the picture open(I want it to be as the image below):

enter image description here

This is how it looks like when i load the image in landscape mode:

enter image description here

1
Do you listen for orientation change event? Like UIDevice.currentDevice(). beginGeneratingDeviceOrientationNotifications() etc. - Juri Noga

1 Answers

0
votes

Add a orientation change listener:

NSNotificationCenter.defaultCenter().addObserver(self, selector: "deviceDidRotate", name: UIDeviceOrientationDidChangeNotification, object: nil)

And then implement deviceDidRotate method:

func deviceDidRotate(){

    if(UIDeviceOrientationIsLandscape(UIDevice.currentDevice().orientation)){            
        scrollView.zoomScale = 0.50
    }

    if(UIDeviceOrientationIsPortrait(UIDevice.currentDevice().orientation)){
        scrollView.zoomScale = 0.25
    }

}