setContentOffset失去精度?

Ser*_*nce 5 iphone cocoa-touch objective-c uiscrollview ios

我有一个应用程序,我需要初始化contentOffsetUIScrollView,以一定的价值.我注意到当我设置contentOffset它时,它将点向上舍入到最接近的整数.我尝试过使用两者setContentOffset并且setContentOffset:animated仍然得到相同的结果.当我尝试手动添加contentOffset到帧原点时,我没有得到我想要的结果.任何人都知道这个吗?

UIScrollView *myScrollViewTemp = [[UIScrollView alloc] initWithFrame: CGRectMake(CropThePhotoViewControllerScrollViewBorderWidth, CropThePhotoViewControllerScrollViewBorderWidth, self.myScrollViewBorderView.frame.size.width - (CropThePhotoViewControllerScrollViewBorderWidth * 2), self.myScrollViewBorderView.frame.size.height - (CropThePhotoViewControllerScrollViewBorderWidth * 2))];
[self setMyScrollView: myScrollViewTemp];
[[self myScrollView] setAutoresizingMask: UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
[[self myScrollView] setShowsVerticalScrollIndicator: NO];
[[self myScrollView] setShowsHorizontalScrollIndicator: NO];
[[self myScrollView] setBouncesZoom: YES];
[[self myScrollView] setDecelerationRate: UIScrollViewDecelerationRateFast];
[[self myScrollView] setDelegate:self];
[[self myScrollViewBorderView] addSubview: [self myScrollView]];
[myScrollViewTemp release];

UIImageView *myImageViewTemp = [[UIImageView alloc] initWithImage: self.myImage];
[self setMyImageView: myImageViewTemp];
[[self myScrollView] addSubview:[self myImageView]];
[[self myScrollView] setContentSize: [self.myImage size]];
[[self myScrollView] setMinimumZoomScale: self.previousZoomScale];
[[self myScrollView] setMaximumZoomScale: 10];
[[self myScrollView] setZoomScale: self.previousZoomScale animated:NO];
[[self myScrollView] setContentOffset: self.contentOffset animated:NO];
[myImageViewTemp release];
Run Code Online (Sandbox Code Playgroud)

更新:更新的代码.

Ser*_*nce 2

看来这不是我的错误,而是苹果有意或无意的预期行为。为了解决这个问题,您需要在 UIViewController 的 viewWillLayoutSubviews 方法中设置 contentOffset。显然,您需要在设置整个视图框架后设置 contentOffset。