我有 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模板网!