在UIScrollView内的UIImageView中添加捏/缩放效果 [英] Adding Pinch/Zoom effect to a UIImageView inside a UIScrollView
问题描述
我有一个非常基本的屏幕共享iPhone应用程序,我已经使用 UIScrollView
内的 UIImageView
将捏/缩放效果成功添加到了我的应用程序中.
I have a very basic screen sharing iPhone app, I have successfully added the pinch/zoom effect to my app using a UIImageView
inside a UIScrollView
.
UIImageView
定期接收来自PC的屏幕内容.一切都正常,但是一旦我滚动/捏/缩放就可以了,但随后它停止了,即使服务器仍然发送屏幕内容,更新图像视图内容的委托方法也停止启动.整个应用似乎被冻结了,但是没有错误消息/异常/任何信息.有人可以帮我吗?
The UIImageView
receives the screen content from the PC on a regular interval. Everything works fine but as soon as I scroll/pinch/zoom it works at first but then it stops, and the delegate method that's updating the image view content stops firing up even though the server still sends the screen content. The whole app seems to be frozen but there are no error messages/exceptions/whatever. Can anyone help me, please?
推荐答案
如果使用的是 NSDefaultRunLoopMode
,则 UIAPPlication
会添加运行循环模式 UITrackingRunLoopMode
用于跟踪滚动等滚动视图事件.由于 UIApplication
从 NSDefaultRunLoopMode
切换到 UITrackingRunLoopMode
,因此直到 UIAPPlication
切换回 NSDefaultRunLoopMode
.
If you are using NSDefaultRunLoopMode
, UIAPPlication
adds a run loop mode UITrackingRunLoopMode
for tracking scrollview events like scrolling. Since the UIApplication
switches from NSDefaultRunLoopMode
to UITrackingRunLoopMode
any events on NSDefaultRunLoopMode
will not be called until UIAPPlication
switch back to NSDefaultRunLoopMode
.
可能是问题所在,解决方法是将 NSDefaultRunLoopMode
更改为 NSRunLoopCommonModes
.
It might be the problem, the fix is change NSDefaultRunLoopMode
to NSRunLoopCommonModes
.
如果您不确定是否正在使用runloop(如注释中所述).只需在您的项目中搜索 NSDefaultRunLoopMode
.
If you are not sure whether you are using runloop or not as you mentioned in comment. Just search NSDefaultRunLoopMode
in your project.
这篇关于在UIScrollView内的UIImageView中添加捏/缩放效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!