UIScrollViewDelegate
有一个新的真棒方法:检查协议方法被定义
// called on finger up if the user dragged. velocity is in points/second. targetContentOffset may be changed to adjust where the scroll view comes to rest. not called when pagingEnabled is YES
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView
withVelocity:(CGPoint)velocity
targetContentOffset:(inout CGPoint *)targetContentOffset __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_5_0)
然而,这是只在iOS 5中。对于没有这种方法的iOS,我想使用分页作为替代。所以,我有两种选择:
- 检查iOS版本,我不知道该怎么办,或
- 检查是否这种方法为
UIScrollViewDelegate
协议定义,我也不知道该怎么办。
我宁愿以某种方式检查方法是否在协议中定义,而不是检查iOS版本。请注意,执行respondsToSelector:
检查是不够的,因为我的类实现协议将始终定义它。
+1关于协议成员可用性的有趣问题。 – Till