UIScrollView具有大的contentSize但不滚动 - 没有autoLayout

时间:2016-03-19 21:23:03

标签: ios swift uiscrollview uiimageview

在我的Swift 2 iOS 9.0项目中,我已经设置了一个带有UIImageView和一些按钮和标签的UIScrollView。由于某些其他原因,scrollView的帧为652点宽,652点高。其内容由imageView中的图像决定(它是1000x1000):

func loadImageOntoView(FloorImage:UIImage) -> Void {

mapImageView.image = FloorImage
    // containerView is my root view, same size as the screen
    let cw = containerView.frame.width
    let ch = containerView.frame.height
    let cd = sqrt(cw*cw + ch*ch)

    /* Here I set scrollView's frame to be a square with sides as 
    long as containerView's diagonal. This makes sure that if the scrollView
    is rotated it's always bigger than the screen*/
    scrollView.frame = CGRect(
        x: -(cd-cw)/2, y: -(cd-ch)/2,
        width: cd, height: cd
    )
    scrollView.contentSize = FloorImage.size

    //Here it centers the imageView in the scrollView
    mapImageView.center = CGPoint(
        x: scrollView.frame.size.width/2, y: scrollView.frame.size.height/2)

    scrollView.minimumZoomScale = 0.9
    scrollView.maximumZoomScale = 15.1
} 

我对这些scrollViews并不完全确定,但我认为应该可以使用这些设置进行滚动?当我放大时我可以滚动,但是当zoomScale = 1时它不起作用。我做错了什么,或者我应该如何使用scrollViews?

0 个答案:

没有答案
相关问题