简体   繁体   中英

UIScrollView in UITableVIewCell won't scroll

I have a UITableView with scrolling disabled.

In a UITableViewCell , I have a UIScrollView .

In the UITableViewCell subclass, I've implemented :

-(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 ? I've done the same kind of thing in an other app with a UICollectionView in a UITableView and it worked well though.

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.

More information here : Button in UITableViewCell not responding under ios 7

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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