gpt4 book ai didi

iphone - setContentOffset 失去精度?

转载 作者:可可西里 更新时间:2023-11-01 04:44:38 35 4
gpt4 key购买 nike

我有一个应用程序,我需要将 UIScrollViewcontentOffset 初始化为某个值。我注意到当我设置 contentOffset 时,它会将点四舍五入为最接近的整数。我已经尝试同时使用 setContentOffsetsetContentOffset: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];

更新:更新代码。

最佳答案

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

关于iphone - setContentOffset 失去精度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10451385/

35 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com