问题描述
我有 DiscountListTableViewController 在我的应用程序中显示为单独的屏幕.但是还有另一个屏幕 (PlaceDetailsViewController) 我需要在底部显示相关折扣.
I have DiscountListTableViewController that is shown as a separate screen in my app. But there's another screen (PlaceDetailsViewController) where I need to show related discounts at the bottom.
目前,PlaceDetailsViewController.view 将 UIScrollView 作为容器,我将 DiscountListTableViewController.tableView 添加到此 UIScrollView. 容器.这有效,表格视图显示正确,但无法接收单元格点击.PlaceDetailsViewController 的 viewDidLoad 中的 content
Currently, PlaceDetailsViewController.view has UIScrollView as a container and I'm adding DiscountListTableViewController.tableView to the this UIScrollView.content container in viewDidLoad of PlaceDetailsViewController. This works and the table view is shown correctly, however unable to receive cell clicks.
我知道 UITableView 继承自 UIScrollView 并且不知何故不建议(但不受限制).但是,从松耦合的角度来看,每个组件都应该以可以在其他地方独立使用的方式设计,在我的例子中是 DiscountListTableViewController.
I know UITableView inherits from UIScrollView and it's somehow not advised (but not restricted). However, from loose coupling point of view, every component should be designed in a way it could be independently used elsewhere, and it's DiscountListTableViewController in my case.
PlaceDetailsViewController 组件只需要 DiscountListTableViewController 原样,所以没有逻辑原因不能直接使用.有什么建议?
PlaceDetailsViewController component just needs DiscountListTableViewController as-is, so there's no logic reason why it can't be used directly. Any suggestions?
推荐答案
答案:不要这样做.
UITableview 继承自 ----> UIScrollView : UIView : UIResponder : NSObject
UITableview is inherited from ----> UIScrollView : UIView : UIResponder : NSObject
苹果说:
重要提示:您不应将 UIWebView 或 UITableView 对象嵌入UIScrollView 对象.如果这样做,可能会导致意外行为因为两个对象的触摸事件可能会混淆和错误处理.
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.
这篇关于如何在 UIScrollView 中使用 UITableView 并接收单元格点击?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)