简体   繁体   English

UITableVIewCell中的UIScrollView将不会滚动

[英]UIScrollView in UITableVIewCell won't scroll

I have a UITableView with scrolling disabled. 我有一个UITableView滚动的UITableView

In a UITableViewCell , I have a UIScrollView . UITableViewCell ,我有一个UIScrollView

In the UITableViewCell subclass, I've implemented : UITableViewCell子类中,我实现了:

-(void)layoutSubviews
{    
    [mainScrollView addSubview:mainContentView];
    mainScrollView.contentSize = mainContentView.bounds.size;
    mainScrollView.scrollEnabled = YES;
}

This method is called and the content size is correctly set. 调用此方法,并正确设置内容大小。

But the UIScrollView won't scroll... Do you thing it might come form the UITableView ? 但是UIScrollView不会滚动...你觉得它可能来自UITableView吗? I've done the same kind of thing in an other app with a UICollectionView in a UITableView and it worked well though. 我在另一个应用程序中用UITableViewUICollectionView完成了同样的事情,但是效果很好。

I got it ! 我知道了 !

What worked for me is this: 对我有用的是:

contentView.userInteractionEnabled = NO;

called after loading my custom cell from nib. 从笔尖加载我的自定义单元格后调用。 It looks like this content view is created and set as a top-level child view after creating views defined in the nib file. 在创建nib文件中定义的视图之后,似乎已创建了该内容视图并将其设置为顶级子视图。

More information here : Button in UITableViewCell not responding under ios 7 这里的更多信息: UITableViewCell中的按钮在iOS 7下不响应

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM