Loc*_*ike 10 uiscrollview nsrunloop ios
我想模仿UIScrollView行为,当你拖动scrollView时当前线程RunLoop模式更改为UITrackingRunLoopMode,并在停止拖动时返回NSDefaultRunLoopMode.
我想用我自己的类来做,但是拖着视图......现在我正在使用这段代码
while (_draggingView && [[NSRunLoop currentRunLoop] runMode:UITrackingRunLoopMode beforeDate:[NSDate distantFuture]]);
当我停止拖动时,_draggingView更改为nil,因此我停止在该模式下循环.这样做有更优雅/更好的方式吗?
UIScrollView是如何做到的?输入源?
谢谢
您可以使用CFRunLoopStop强制运行循环返回。
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
    [super touchesEnded:touches withEvent:event];
    CFRunLoopStop(CFRunLoopGetMain());
}
| 归档时间: | 
 | 
| 查看次数: | 1831 次 | 
| 最近记录: |