iphone - 如何在 UIScrollView 中使用 UITableView 并接收单元格点击?

标签 iphone ios objective-c uitableview uiscrollview

我有 DiscountListTableViewController在我的应用程序中显示为单独的屏幕。但是还有另一个屏幕(PlaceDetailsViewController),我需要在底部显示相关折扣。

目前,PlaceDetailsViewController.viewUIScrollView作为一个容器,我要添加 DiscountListTableViewController.tableView到这个UIScrollView.content viewDidLoad 中的容器的 PlaceDetailsViewController .这有效并且表格 View 正确显示,但无法接收单元格点击。

我知道UITableView继承自 UIScrollView并且不知何故不建议(但不受限制)。但是,从松散耦合的角度来看,每个组件都应该以可以在其他地方独立使用的方式设计,它是 DiscountListTableViewController就我而言。
PlaceDetailsViewController组件只需要DiscountListTableViewController按原样,所以没有逻辑理由不能直接使用它。有什么建议么?

最佳答案

答案:不要这样做。
UITableview继承自----> UIScrollView : UIView : UIResponder : NSObject
苹果说:

Important: You should not embed UIWebView or UITableView objects in UIScrollView objects. If you do so, unexpected behavior can result because touch events for the two objects can be mixed up and wrongly handled.

关于iphone - 如何在 UIScrollView 中使用 UITableView 并接收单元格点击?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17121488/

相关文章:

ios - 如何将 UIColor 转换为 UInt32 ?我收到错误 Ambiguous use of operator "+="

ios - UIScrollview 停留在不正确的 contentOffset(-20 像素,而不是 0 像素)

iphone - 如何为 UIButton 的文本添加换行符?

iphone - 有人有使用 YAJL 的 Objective-C 绑定(bind)的经验吗?

iphone - UIImageView 不遵循 origin.x 位置

iPhone应用程序崩溃: Assertion failed function evict_glyph_entry_from_strike,文件Fonts/CGFontCache.c

ios - XCode 8.0 应用构建超慢

ios - swift 2 中 Collectionview 多个部分的不同滚动方向

ios - 混合 midi 文件,每个文件都有自己的声音字体

iphone - 当相机前面有一些移动时,是否可以通过编程方式从我的 iPhone 拍照?