问题描述
i upgraded to Xcode 4.5 and have started using the iOS SDK 6.0:
i have a universal app that had been developed with Xcode 4.4 and the iOS SDK 5.1
and it had been running on all devices and simulators tested without any glitches.
in hope of having it continue to work on the iPhone 5, i wanted to provide the proper launch-image and let it run.
many parts of the app work without changes, but one part of it does not: an image that i have placed in a UIScrollView does not pan. this has always worked previously, but not on the iOS 6 simulator.
to the real crux of the problem, though: when i went to run on the iOS 5.0 or iOS 5.1 simulators, in my debug log, i am seeing an exception thrown as follows:
-[NSKeyValueMethodSetter setMaximumNumberOfTouches:]: unrecognized selector sent to instance 0x6ddab20
the stack crawl shows that the code attempting to make this call is UIScrollView setMinimumZoomScale
.
my code to call setMimimumZoomScale is as follows:
CGFloat widthScale = self.scrollView.bounds.size.width / self.image.size.width;
CGFloat heightScale = self.scrollView.bounds.size.height / self.image.size.height;
// just reset the zoom scales; leave center and everything else where possible
self.scrollView.minimumZoomScale = MIN(1.0, MIN(widthScale, heightScale));
self.scrollView.maximumZoomScale = 4.0;
the thrown exception (and subsequent crash) occur on that first call to setMimimumZoomScale with the message noted above.
i am guessing that Xcode 4.5 is using code for setMinimumZoomScale that calls sends that message, which probably exists in the library for iOS 6, but never did in iOS 5.
are others seeing a similar problem?
fwiw, i have not touched my .storyboard files, so they would still be set to work without autoLayout.
do i have to go back and install Xcode 4.4 beside Xcode 4.5 in order to be able to continue to allow my working app to be maintained?
answering my own question …
the complexity of my original question involved additional gesture recognizers.
under iOS 5.1 SDK (and some prior), it was possible to add a gesture recognizer to UIScrollView and be able to have it work in conjunction with panGestureRecognizer and pinchGestureRecognizer that are built into the UIScrollView.
under iOS 6.0 SDK, this behavior is apparently no longer really supported. the relevant documentation does not so much explicitly forbid the behavior as it does define what the UIScrollView will do for touches that may or may not be related to pan and pinch.
Because a scroll view has no scroll bars, it must know whether a touch signals an intent to scroll versus an intent to track a subview in the content. To make this determination, it temporarily intercepts a touch-down event by starting a timer and, before the timer fires, seeing if the touching finger makes any movement. If the timer fires without a significant change in position, the scroll view sends tracking events to the touched subview of the content view. If the user then drags their finger far enough before the timer elapses, the scroll view cancels any tracking in the subview and performs the scrolling itself. Subclasses can override the touchesShouldBegin:withEvent:inContentView:, pagingEnabled, and touchesShouldCancelInContentView: methods (which are called by the scroll view) to affect how the scroll view handles scrolling gestures.
in order to rectify the problem, i had to make sure that the gesture recognizers in the storyboard are no longer part of the collection associated with the scrollview, and instead associate them with the content-view of the scrollview.
(in my case, in order to do this, i had to manually add them using addGestureRecognizer:
for each gesture-recognizer i am interested in, since the content-view is for images that aren't known at storyboard time.)
这篇关于在 iOS 5 模拟器上运行时,使用 iOS 6.0 SDK 并为 iOS 5 Target 构建会导致 UIScrollView setMinimumZoomScale 失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!