0
- (void)centerScrollViewContents {
CGSize boundsSize = self.scrollView.bounds.size;
CGRect contentsFrame = self.imageView.frame;
if (contentsFrame.size.width < boundsSize.width) {
contentsFrame.origin.x = (boundsSize.width - contentsFrame.size.width)/2.0f;
} else {
contentsFrame.origin.x = 0.0f;
}
if (contentsFrame.size.height < boundsSize.height) {
contentsFrame.origin.y = (boundsSize.height - contentsFrame.size.height)/2.0f;
} else {
contentsFrame.origin.y = 0.0f;
}
self.imageView.frame = contentsFrame;
}
我在viewWillAppear
中調用了conterScrollViewContents
方法,但imageView不會定位到scrollView的中心。無法將imageview放置到中心
有什麼問題?
謝謝你的回答,我剛解決了這個問題。我沒有設置imageView的代表。 – Weizhi 2012-07-08 03:16:15