[英]Scroll horizontally UIScrollView inside UITableViewCell
I know this issue isn't new and there are many similar questions like this on this site. 我知道这个问题并不新鲜,并且在此站点上有很多类似的问题。 I've checked most of them but cannot find the answer.
我已经检查了大多数,但找不到答案。 I have a UITableView.
我有一个UITableView。 Inside each UITableViewCell, I insert some of subviews (same level).
在每个UITableViewCell中,我插入一些子视图(相同级别)。 One of subviews is a UIScrollView that I use to add some UIIMageView to scroll horizontally.
子视图之一是UIScrollView,我用于添加一些UIIMageView来水平滚动。 The ScrollView is the bottom subviews (other subviews are above this ScrollView).
ScrollView是底部子视图(其他子视图在此ScrollView上方)。 I've made a test project and pushed to GitHub: https://github.com/lenhhoxung86/PageControlDemo .
我已经完成了一个测试项目,并推送到GitHub: https : //github.com/lenhhoxung86/PageControlDemo 。 The project works file and I noticed that delegate method:
该项目的工作文件,我注意到该委托方法:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
is not called but it's just fine. - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
不调用- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
但很好。
However, when I moved this code into my real project, it doesn't work and the delegate method of tableview (didselectRowAtIndexPath) is actually called. 但是,当我将此代码移到我的真实项目中时,它不起作用,并且实际上调用了tableview的委托方法(didselectRowAtIndexPath)。
Can anybody help me fix this? 有人可以帮我解决这个问题吗? I'm going to insane for this issue.
我要为这个问题疯狂。 Following is picture captured on my test project
以下是我的测试项目中捕获的图片
Finally I found the cause. 终于我找到了原因。 In my test project, I used a Xib file created when I created a custom class of UITableViewCell.
在测试项目中,我使用了创建UITableViewCell的自定义类时创建的Xib文件。 The view object is kind of class UITableViewCell by default.
默认情况下,视图对象是类UITableViewCell。 In my real project, I created custom class UITableViewCell first then created many Xib files so that I can load them when I need.
在我的真实项目中,我首先创建了自定义类UITableViewCell,然后创建了许多Xib文件,以便可以在需要时加载它们。 By default, these View objects in these Xib files are kind of UIView.
默认情况下,这些Xib文件中的这些View对象都是UIView。 I re-created Xib file that belongs to class UITableView by default then it works.
我重新创建了默认情况下属于类UITableView的Xib文件,然后它可以工作。 I have no idea how to convert existed Xib file with object of UIView type to UITableView.
我不知道如何将具有UIView类型的对象的现有Xib文件转换为UITableView。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.