0

I was trying to find solution almost everywhere, but I didn't find it. So, here is my problem.

I have UITableView with custom UITableViewCells.

  1. The first cell has UIScrollView inside its Content View.
  2. The Second cell has UILables and other basic views inside its Content View.

So, if there is UIScrollView inside the first cell, content of the second cell disappears. It appears only if the first cell scrolls out of the tableView frame.

Can anybody help me figure it out? Thank you.

Code preview

#pragma mark - UITableView Data Source

-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    if ([indexPath isEqual:_photosIndexPath]) {
        static NSString *PhotosCellIdentifier = @"AdDetailsPhotosCell";
        BazarAdDetailPhotosCell *cell = [tableView dequeueReusableCellWithIdentifier:PhotosCellIdentifier];
        if (!cell) {
            cell = [[BazarAdDetailPhotosCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:PhotosCellIdentifier];
        }
        cell.photoScrollView.scrollsToTop = NO;
        cell.photoScrollView.delegate = cell;

        [cell setPhotos:_adDetail.photos];

        return cell;
    }
    else if ([indexPath isEqual:_adDetailsPath]) {
        static NSString *DetailsCellIdentifier = @"AdDetailsDetailCell";
        BazarAdDetailsDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:DetailsCellIdentifier];
        if (!cell) {
            cell = [[BazarAdDetailsDetailCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:DetailsCellIdentifier];
        }

        cell.adTitleLabel.text = _adDetail.title;
        cell.priceLabel.text = _adDetail.price;
        // this cell content disappears
    }
}

View hierarchy

Content in cells below cell with UIScrollView disappears

Connections of the Cell with UIScrollView

petesalt
  • 356
  • 3
  • 20
  • please share some code you have tried – DareDevil Mar 11 '14 at 09:07
  • It looks like you have two different `UITableViewCells` and you're overwriting one of them when scrolling. But without sharing your `UITableViewDelegates` like `cellForRowAtIndexPath:` and maybe a screenshot of your nib and the connections of your `UITableViewCells` we can't help you – Alex Cio Mar 11 '14 at 09:10
  • if it is ios7 only issue it can be because of UiScrollView's `automaticallyAdjustsScrollViewInsets` property which defaults to NO. Set it to yes and check. – iPP Mar 11 '14 at 09:13
  • I have added some code and images. – petesalt Mar 11 '14 at 09:28
  • It worked yesterday, but when I have updated to iOS 7.1 this started to happen. `automaticallyAdjustsScrollViewInsets` doesn't work. – petesalt Mar 11 '14 at 09:32
  • Sorry, set it to NO. Also check your autoresizing masks. If there are any conflicts. – iPP Mar 11 '14 at 09:59

2 Answers2

3

Might be issue with cell drawing on iOS 7.1, according answer on iOS 7.1 beta5 tableviewcell height showing objects outside it's range, try to clip subviews:

cell.clipsToBounds = YES;
Community
  • 1
  • 1
tyorke
  • 46
  • 1
0

Try it

  #pragma mark - UITableView Data Source

-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    if ([indexPath isEqual:_photosIndexPath]) 
{
        static NSString *PhotosCellIdentifier = @"AdDetailsPhotosCell";
        BazarAdDetailPhotosCell *cell = [tableView dequeueReusableCellWithIdentifier:PhotosCellIdentifier];
        if (!cell) {
            cell = [[BazarAdDetailPhotosCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:PhotosCellIdentifier];
        }
        cell.photoScrollView.scrollsToTop = NO;
        cell.photoScrollView.delegate = cell;

        [cell setPhotos:_adDetail.photos];

        return cell;
    }
    else  {
        static NSString *DetailsCellIdentifier = @"AdDetailsDetailCell";
        BazarAdDetailsDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:DetailsCellIdentifier];
        if (!cell) {
            cell = [[BazarAdDetailsDetailCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:DetailsCellIdentifier];
        }

        cell.adTitleLabel.text = _adDetail.title;
        cell.priceLabel.text = _adDetail.price;
        // this cell content disappears
 return cell;
    }
}
Muralikrishna
  • 1,044
  • 10
  • 17
  • Doesn't work. I have tried to insert some content to the second cell, but also disappears. – petesalt Mar 11 '14 at 09:50
  • Content still disappears. It is weird. – petesalt Mar 11 '14 at 09:56
  • _adDetail its array or dict or object how you getting data for uitableview cell .UiTAble scrolling time reload the data that you must maintain useing array or dict or objects of array count must be same for both cells – Muralikrishna Mar 11 '14 at 09:59
  • _adDetail is object the same for all the cells. Every cell only shows different data from this object. – petesalt Mar 11 '14 at 10:01