objective-c - iOS上ScrollView上的Button问题
PHP中文网
PHP中文网 2017-04-18 09:22:44
0
2
235

button添加到ScrollView上,点击效果没了。
通过设置ScrollView.delaysContentTouches = NO;
点击效果回来了,但是button区域的滑动ScrollView失效。
因为button较多所以设置上面的那个不行 有没有好的解决办法。

PHP中文网
PHP中文网

认证高级PHP讲师

全部回覆(2)
黄舟

1、定一個UIScrollView類,重寫以下方法

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
    [[self nextResponder] touchesBegan:touches withEvent:event];
    [super touchesBegan:touches withEvent:event];
}

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    [[self nextResponder] touchesMoved:touches withEvent:event];
    [super touchesMoved:touches withEvent:event];
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
    [[self nextResponder] touchesEnded:touches withEvent:event];
    [super touchesEnded:touches withEvent:event];
}

這樣就可以獲取到button 的點擊事件了,具體是因為什麼給你個鏈接即看一下
鏈接描述

Peter_Zhu

能不能在 scrollView 上放個 view

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!