久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

UIButton 在 UIScrollView 中不起作用

UIButton does not work when it in UIScrollView(UIButton 在 UIScrollView 中不起作用)
本文介紹了UIButton 在 UIScrollView 中不起作用的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我的觀點結構:

UITableView
  UITableViewCell
    UIScrollView
      CustomView
        UIButton

問題是當我觸摸 UIButton 時它不起作用.我用代碼創建它:

The problem is UIButton doesn't work when I touch it. I create it with code:

btn = [[UIButton alloc] init];
[btn setImage:image forState:UIControlStateNormal];
[btn addTarget:self action:@selector(tileTouchUpInside) forControlEvents:UIControlEventTouchUpInside];
btn.layer.zPosition = 1;
[self addSubview:btn];

我也添加了這個:

scroll.delaysContentTouches = NO;
scroll.canCancelContentTouches = NO;

但我的按鈕無論如何都不起作用.我無法為 UITableView 取消ContentTouches 或設置延遲,因為如果我設置它,UITableView 將停止垂直滾動.

But my button doesn't work anyway. I can't cancelContentTouches or set delay for UITableView because if I set it, UITableView stop scrolling verticaly.

感謝您的幫助!

推薦答案

創建UIScrollview的子類

Create a subclass of UIScrollview with

- (BOOL)touchesShouldCancelInContentView:(UIView *)view {
  return NO;
}

如果您沒有收到該消息,請設置:

If you are not getting that message, set:

scrollView.delaysContentTouches = NO;

問題在于 touchesShouldCancelInContentView 默認的行為方式,僅當子視圖是 UIControl 時它才返回 NO,但您的按鈕隱藏在 CustomView 中,但不是.

The problem is because of the way touchesShouldCancelInContentView behaves by default, it returns NO only if the subview is an UIControl, but your button is hidden inside the CustomView which isn't.

這篇關于UIButton 在 UIScrollView 中不起作用的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

How to subclass UIScrollView and make the delegate property private(如何繼承 UIScrollView 并使委托屬性私有)
Swift - how to get last taken 3 photos from photo library?(Swift - 如何從照片庫中獲取最后拍攝的 3 張照片?)
Setting contentOffset programmatically triggers scrollViewDidScroll(以編程方式設置 contentOffset 觸發 scrollViewDidScroll)
Photos app-like gap between pages in UIScrollView with pagingEnabled(使用 pagingEnabled 的 UIScrollView 中頁面之間的照片應用程序式間隙)
why UIScrollView is leaving space from top in ios 6 and ios 7(為什么 UIScrollView 在 ios 6 和 ios 7 中從頂部留下空間)
UIScrollView pauses NSTimer while scrolling(UIScrollView 在滾動時暫停 NSTimer)
主站蜘蛛池模板: 女人牲交视频一级毛片 | 中文字幕二区 | 欧美精品a∨在线观看不卡 欧美日韩中文字幕在线播放 | av一区二区三区在线观看 | 福利成人 | 中文字幕国产 | 国产精品美女久久久久久免费 | 精品久久久久久亚洲综合网 | 99久久精品国产麻豆演员表 | 在线播放一区二区三区 | 欧美一级在线免费 | 亚洲精品国产电影 | 欧美综合视频在线 | 久久国产精品免费一区二区三区 | 亚洲欧洲色视频 | 中国黄色毛片视频 | 蜜桃av人人夜夜澡人人爽 | 国产免费av在线 | 一区二区三区久久久 | 91porn国产成人福利 | 久久99精品久久久久久噜噜 | 久久国产精品网 | 色综合桃花网 | 天天天操天天天干 | 日本精品一区二区三区视频 | 一区二区三区国产在线观看 | 日韩一区二区在线观看视频 | 国产精品乱码一区二区三区 | 日韩不卡三区 | 2020亚洲天堂 | 一区二区国产精品 | 亚洲福利在线观看 | 久久精品在线播放 | 亚洲精品视频网站在线观看 | 欧美日韩在线免费观看 | av日韩在线播放 | 日韩无 | 亚洲天堂中文字幕 | 999精品网| 欧美xxxx性xxxxx高清 | 午夜视频网 |