12207480 / TYCyclePagerView

a simple and usefull cycle pager view ,and auto scroll banner view(轮播图) ,include pageControl for iOS,support Objective-C and swift
MIT License
1.81k stars 334 forks source link

UIViewcontroller实现UIScrollViewDelegate的scrollViewDidScroll方法,导致TYCyclePagerView崩溃 #20

Closed anyonehelps closed 6 years ago

anyonehelps commented 7 years ago

我在UIViewcontroller实现UIScrollViewDelegate的scrollViewDidScroll方法,使用了TYCyclePagerView之后,一运行就崩溃,报错原因是reason: '-[AHHomeViewController pagerViewDidScroll:]: unrecognized selector sent to instance 0x7ff0d5631cf0'。

我看了一下源码,在TYCyclePagerView.m文件的setDelegate:方法里面, _delegateFlags.pagerViewDidScroll = [delegate respondsToSelector:@selector(scrollViewDidScroll:)] 此处是检查delegate是否实现了scrollViewDidScroll:方法,然后在TYCyclePagerView.m 文件里面实现的scrollViewDidScroll方法里面判断_delegateFlags.pagerViewDidScroll是否为真,然后调用的[_delegate pagerViewDidScroll:self]。 如果UIViewcontroller并没有实现pagerViewDidScroll,而只是实现scrollViewDidScroll:方法,就会导致崩溃现象。所以需要修改为 _delegateFlags.pagerViewDidScroll = [delegate respondsToSelector:@selector(pagerViewDidScroll:)]

12207480 commented 6 years ago

好的

12207480 commented 6 years ago

fixed #20