问题描述
限时送ChatGPT账号..我有一个具有以下布局的视图控制器:
I have a view controller with following layout:
容器视图UIScrollView
UITableView
作为 UIScrollView
的子视图
Container View
UIScrollView
UITableView
as a sub view of a UIScrollView
我有另一个 UITableViewController
在其中我有几行和当行被选中时的一些方法.现在我想在 UIScrollView
中显示这个 UITableview
.所以我将 UITableView
添加为 UIScrollView
的子视图.表格在滚动视图中显示得很好,但是当我在滚动视图中点击以选择表格的行时,行会被突出显示,但在选择行时不会调用该方法..
I have another UITableViewController
in which I have a few rows and some methods when the row gets selected. Now I want to display this UITableview
inside the UIScrollView
. So I add the UITableView
as a subview of UIScrollView
. The table is displayed in the scroll view just fine, but when I tap in the scroll view to select the table's row, then row is being highlighted but the method is not getting called when the row is selected..
PBDashboardPickupTable *dashtable = [[PBDashboardPickupTable alloc]initWithNibName:@"PBDashboardPickupTable" bundle:nil];
[self.scrollView addSubview:dashtable.tableView];
我还从界面生成器将滚动视图的 delayContentTouches
设置为 YES
并将 cancelContentTouch
设置为 NO
.另外 userInteractionEnabled
设置为 YES
... 那么为什么当我点击 table view 的行时没有调用该方法?
Also I have set scroll view's delayContentTouches
to YES
and cancelContentTouch
to NO
from Interface Builder. Also userInteractionEnabled
is set to YES
... then why is the method not getting called when I tap the table view's row?
推荐答案
Apple 在文档中特别警告避免将 UITableView
放在 UIScrollView
中:
Apple specifically warns in the documentation to avoid putting a UITableView
inside of a UIScrollView
:
重要:您不应在 UIScrollView
对象中嵌入 UIWebView
或 UITableView
对象.如果这样做,可能会导致意外行为,因为这两个对象的触摸事件可能会混淆并错误处理.
Important: You should not embed
UIWebView
orUITableView
objects inUIScrollView
objects. If you do so, unexpected behavior can result because touch events for the two objects can be mixed up and wrongly handled.
由于 UITableView
继承自 UIScrollView
,我建议您添加您需要的任何其他视图作为 tableHeaderView
、tableFooterView代码>,或作为表格中的自定义单元格.
Since UITableView
inherits from UIScrollView
, I would suggest you add any additional views you need as a tableHeaderView
, tableFooterView
, or as custom cells in the table.
这篇关于UIScrollView 中的行选择 UITableView 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论