开发者

failed to make a row of clickable buttons in UIScrollView with paging enabled

开发者 https://www.devze.com 2023-01-26 06:08 出处:网络
I am trying to make a row of buttons which can be scrolled horizontally. Like the news items in a feed in the Pulse News Reader app.

I am trying to make a row of buttons which can be scrolled horizontally. Like the news items in a feed in the Pulse News Reader app. I've successful made enabled paging on UIScrollView with the page size same as the width of a button. i.e. 3 buttons on the screen at once, | 1 | 2 | 3 | , if I swipe left, it becomes | 2 | 3 | 4 |. I made this possible by using a method I founded here in stackoverflow:

- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event { 
    if ([self pointInside:point withEvent:event]) { 
 开发者_如何学运维       return scrollView;
    }
   return nil;}

by turning the clipsToBounds to NO in the UIScrollView containing the row of buttons and then overlaying another view on top of it for getting the swipe gestures. It moves and snap to position perfectly!

But now the biggest problem is that I can't click the buttons except the one inside the bound! What should I do to make those button clickable? I thought I can get the touch events and pass it to the UIScrollView containing those buttons, but I found that once the above method is used, I can't get any touchesBegan, touchesEnd, touchesMoved and touchesCancelled response to me.I've been finding way out for days painfully, please point me into a correct direction. Thanks for your attention!

0

精彩评论

暂无评论...
验证码 换一张
取 消