我試圖將低分辨率圖像加載到滾動視圖中,並且在第一次縮放後將其替換爲高分辨率圖像。第一次嘗試不太好。爲了讓我更好地理解正在發生的事情,我現在試圖加載高分辨率圖像,並在第一次縮放後用相同的高分辨率圖像替換它,即建立現狀。在我的viewDidLoad中我有:UIScrollView:無法在縮放後建立現狀
imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"LargeImage.png"]];
[scrollView addSubview:imageView];
scrollView.contentSize = imageView.bounds.size;
scrollView.minimumZoomScale = 1.0;
scrollView.minimumZoomScale = 0.25;
scrollView.zoomScale = 0.251497;
scrollView.clipsToBounds = YES;
scrollView.delegate = self;
這給出:
imageView.frame.size = 420580(滾動視圖的幀)
imageView.bounds.size = 1670,2306
在scrollViewDidEndZooming:我做的:
[imageView removeFromSuperview];
[imageView release];
scrollView.zoomScale = 1.0;
CGRect svb = CGRectZero;
svb.size = scrollView.frame.size;
scrollView.bounds = svb;
imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"LargeImage.png"]];
[scrollView addSubview:imageView];
scrollView.contentSize = imageView.bounds.size;
scrollView.maximumZoomScale = 1.0;
scrollView.minimumZoomScale = 0.25;
scrollView.zoomScale = 0.251497;
這給:
imageView.frame.size = 1670,2306
imageView.bounds.size = 1670,2306
我找不出爲什麼imageView.frame沒有縮放,因爲它在viewDidLoad。任何想法,我在做什麼錯或缺失?
你在哪裏把日誌語句? – 2011-06-15 23:35:46
我已經有NSLog語句「遍佈」,但將zoomScale設置爲0.251497後,NSLog正好處理imageView會生成兩個不同的imageView.frame值。 – user556572 2011-06-16 03:50:30