2012-09-18 26 views
1

我想讓我的Monotouch應用程序中的UIScrollView工作。無論我將SetZoomScale()設置爲它總是忽略我的起始比例。理想情況下,當我啓動時,我想讓它變爲0.5f變焦。UIScrollView不從最小變焦開始

theGraphScrollView = new UIScrollView(theRect); // Half of the screen height, full width of screen 
this.View.AddSubview(theGraphScrollView); 

UIImageView imageView = new UIImageView(thePhotoSource.LoadPhotoFromFile("IMG_0_17.JPG")); 
theGraphScrollView.ContentSize = imageView.Image.Size; // This is much bigger than the screen width and height. 
theGraphScrollView.MaximumZoomScale = 3f; 
theGraphScrollView.MinimumZoomScale = 0.5f; 
theGraphScrollView.SetZoomScale(0.5f, true); 
theGraphScrollView.AddSubview(imageView); 
theGraphScrollView.ViewForZoomingInScrollView += (UIScrollView sv) => { return imageView; }; 

有誰能告訴我我哪裏出錯了。

非常感謝。

回答

3

最後需要SetZoomScale()

ViewForZoomingInScrollView在更改變焦之前應該連接起來。

+0

+1當我輸入我的回覆時回答! :d – cod3monk3y

1

通過致電SetZoomScale,UIScrollView嘗試爲視圖設置動畫,但您既未添加圖像,也未設置您的代理通知theGraphScrollView要放大哪個視圖。

SetZoomScale移動到最後,您將被設置。如果這是在您的ViewDidLoad中,您可能還需要將SetZoomScale的第二個參數設置爲false,以防止在第一次加載視圖時動態顯示圖形。這當然是一個偏好問題。

相關問題