问题描述
我在 UIScrollView 中有一个 UIDatePicker.但是 UIDatePicker 不响应滚动触摸.这是滚动的滚动视图.在网上阅读了一些文档,我将延迟内容触摸"设置为 NO,现在我看到日期选择器开始轻微滚动,但它仍然是最终决定字的滚动视图.我在屏幕上有一些地方,用户可以触摸以滚动视图.那么如何将这两种滚动分开并以正常方式使日期选择器滚动呢?
I have a UIDatePicker inside a UIScrollView. But the UIDatePicker does not respond to scroll touches. It's the scrollview that is scrolling. Reading some docs on the net, I've set "Delay Content Touches" to NO, an now I see the datepicker starting a slight scroll, but it's still the scrollview that take the final word. I have some place on the screen where the user can touch to scroll the view. So how may I separate the two kind of scrolls ans make the datepicker scroll in a normal way ?
感谢您的帮助
推荐答案
使用那个帖子解决了:http://www.alexc.me/UIScrollView-and-uidatepicker/153/一个>
只需在其中创建包含该代码的类:
Just make the class with that code inside it :
UIScrollViewBreaker.h
UIScrollViewBreaker.h
@interface UIScrollViewBreaker : UIScrollView {
}
- (BOOL)touchesShouldBegin:(NSSet *)touches withEvent:(UIEvent *)event inContentView:(UIView *)view;
- (BOOL)touchesShouldCancelInContentView:(UIView *)view;
@end
UIScrollViewBreaker.m
UIScrollViewBreaker.m
@implementation UIScrollViewBreaker
- (BOOL)touchesShouldBegin:(NSSet *)touches withEvent:(UIEvent *)event inContentView:(UIView *)view {
if ([view isKindOfClass:[UIDatePicker class]] || [@"UIPickerTable" isEqualToString:[[view class] description]] ) {
//|| [view isKindOfClass:[UIPicker class]]
return YES;
}
return [super touchesShouldBegin:touches withEvent:event inContentView:view];
}
- (BOOL)touchesShouldCancelInContentView:(UIView *)view {
if ([view isKindOfClass:[UIDatePicker class]] || [@"UIPickerTable" isEqualToString:[[view class] description]] ) {
return NO;
}
return [super touchesShouldCancelInContentView:view];
}
@end
并且在 IB 中,将 UIScrollView 的类设置为 UIScrollViewBreaker.
And in IB, set the class of the UIScrollView to UIScrollViewBreaker.
它已经完成了.
只是不要忘记在视图上留出一些位置让用户滚动滚动视图.
Just don't forget to let some place on the view for the user to let him scroll the scrollview.
这篇关于iPhone - UIScrollView 和 UIDatePicker 滚动冲突:一个干扰第二个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)