久久久久久久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)
主站蜘蛛池模板: 在线成人www免费观看视频 | 日韩www| 人人亚洲 | 欧美一区二区另类 | 欧美一区免费 | 日韩在线精品视频 | 蜜桃特黄a∨片免费观看 | 久草新在线 | 久久精品亚洲欧美日韩精品中文字幕 | 欧美成人免费在线视频 | 亚洲在线 | 人人澡人人射 | 成人在线观看网址 | 91视频在线 | 琪琪午夜伦伦电影福利片 | 精品国产久 | av天天爽 | 久久精品小视频 | 91在线资源 | 中文字幕在线精品 | 欧美一区二区三区在线视频 | 久久亚洲经典 | 成人福利网 | 欧美亚洲视频在线观看 | 久久偷人| 亚洲一区二区三区免费在线观看 | 欧美国产日韩在线观看 | 亚洲日本成人 | 国产十日韩十欧美 | 亚洲成人久久久 | 一级日批片 | 亚洲日韩欧美一区二区在线 | 欧美国产日韩一区二区三区 | 国产精产国品一二三产区视频 | 99久久久久久久 | 久久99精品国产自在现线小黄鸭 | 黄色一级片在线播放 | www国产成人免费观看视频,深夜成人网 | 国产蜜臀97一区二区三区 | 91精品国产色综合久久不卡98 | 欧美精品网 |