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

UIButton 在 UIScrollView 中不起作用

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

問題描述

我的觀點結(jié)構(gòu):

UITableView
  UITableViewCell
    UIScrollView
      CustomView
        UIButton

問題是當(dāng)我觸摸 UIButton 時它不起作用.我用代碼創(chuàng)建它:

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 或設(shè)置延遲,因為如果我設(shè)置它,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.

感謝您的幫助!

推薦答案

創(chuàng)建UIScrollview的子類

Create a subclass of UIScrollview with

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

如果您沒有收到該消息,請設(shè)置:

If you are not getting that message, set:

scrollView.delaysContentTouches = NO;

問題在于 touchesShouldCancelInContentView 默認(rèn)的行為方式,僅當(dāng)子視圖是 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.

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

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

相關(guān)文檔推薦

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(以編程方式設(shè)置 contentOffset 觸發(fā) scrollViewDidScroll)
Photos app-like gap between pages in UIScrollView with pagingEnabled(使用 pagingEnabled 的 UIScrollView 中頁面之間的照片應(yīng)用程序式間隙)
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)
主站蜘蛛池模板: 成人片在线播放 | 日韩手机在线视频 | 成人在线免费网站 | 国产精品日韩欧美 | 精东影业一区二区三区 | 欧美日韩在线播放 | 亚洲精品久久 | 日韩网站在线观看 | 免费性视频| 日韩欧美在线播放 | 国产又粗又黄又爽又硬的视频 | 亚洲三级在线观看 | 亚洲激情在线视频 | 三级福利视频 | 亚洲精品91 | www.av在线播放 | 黄色在线免费网站 | 97精品国产97久久久久久免费 | 91插插插插插 | 日本在线不卡视频 | 国产成年妇视频 | 久草网站| 日韩一区三区 | 久久久二区 | 欧美成在线 | 草逼视频免费看 | 麻豆做爰免费观看 | 成人在线网址 | 国产a级大片 | 国产精品偷乱一区二区三区 | 日韩午夜在线观看 | 91精品国产日韩91久久久久久 | 伊人成人在线视频 | 国产ts系列| 亚洲国产精品一区二区三区 | 国产福利在线播放 | 五月天婷婷激情 | 国产一区不卡 | 四虎新网址 | 一级黄色片免费 | 中文在线播放 |