1

我正在做一些看起来应该非常简单的事情,但是我看到了我无法理解的奇怪结果。

我有 a 的UIImageView内部(和大小) a UIScrollViewiOS它是运行它的设备的大小。所有这些都在 IB 中定义。

我有委托方法定义

- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
{
    return storeImageView;
}

缩放时,我看到调用了以下委托方法:

viewForZoomingInScrollView
viewForZoomingInScrollView
viewForZoomingInScrollView
scrollViewWillBeginZooming
scrollViewDidZoom
scrollViewDidScroll scrollView contentOffset: NSPoint: {23.675083, 18.840801}
scrollViewDidZoom
scrollViewDidScroll scrollView contentOffset: NSPoint: {44.748684, 35.630745}
… REPEATED MANY TIMES...
scrollViewDidZoom
scrollViewDidScroll scrollView contentOffset: NSPoint: {782.82373, 588.79358}
scrollViewDidZoom
scrollViewDidScroll scrollView contentOffset: NSPoint: {791.22223, 594.99152}
scrollViewDidZoom
scrollViewDidScroll scrollView contentOffset: NSPoint: {791, 595}
scrollViewDidEndZooming scale factor: 2.498063
scrollViewDidEndZooming scrollView frame: NSRect: {{0, 0}, {768, 1024}}
scrollViewDidEndZooming scrollView bounds: NSRect: {{791, 595}, {1024, 768}}
scrollViewDidEndZooming view frame: NSRect: {{0, 0}, {2558.0161, 1918.5121}}
scrollViewDidEndZooming view bounds: NSRect: {{0, 0}, {1024, 768}}
scrollViewDidEndZooming scrollView contentOffset: NSPoint: {791, 595}
scrollViewDidScroll scrollView contentOffset: NSPoint: {-0, -0}
RE-WORK IMAGE AND DRAW NOW

令人困惑并导致图像移动的是最后一个scrollViewDidScroll重置contentOffset为 {0,0}。看来我一定是无意中留下了导致这种行为的属性集或未设置,但我还没有找到它是什么。

任何建议的提示将不胜感激。

4

1 回答 1

2

解决方案是禁用自动布局。

于 2013-09-20T15:32:11.713 回答