UIScrollViewDelegate
has a new awesome method:
// 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)
However, this is ONLY available in iOS 5. For iOS's without this method, I'd like to use paging as an alternative. So I'm left with two options:
UIScrollViewDelegate
protocol, which I also don't know how to do.I would prefer to somehow check if the method is defined in the protocol rather than checking the iOS version. Note that doing a respondsToSelector:
check won't be adequate since my class implementing the protocol will always define it.
BOOL isAtLeastIOS5 = [[[UIDevice currentDevice] systemVersion] floatValue] >= 5.0;
See How to test a protocol for a method? to test the protocol for a given method.