我有 DiscountListTableViewController
在我的应用程序中显示为单独的屏幕。但是还有另一个屏幕(PlaceDetailsViewController
),我需要在底部显示相关折扣。
目前,PlaceDetailsViewController.view
有 UIScrollView
作为一个容器,我要添加 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/