mcgtrt
mcgtrt

Reputation: 787

ScrollBar always visible

I found great piece of code under the link here. But in my case there is more to do.
My main VC is a UITableViewController. Controller can display two type of cells. One of them (MyCell) is having a subview of type UITextView (textView). The size of it's text is based on fontSize variable. I have two buttons that can lower or greater the fontSize, then both reloads the tableView. According to the link above and having in mind that UITextView is a subclass of UIScrollView, I made my piece of code I placed in didEndDisplayingCell:

-(void)tableView:(UITableView *)tableView didEndDisplayingCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (cell.class == [ConduiteTableCellView class])
    {
        ConduiteTableCellView *conduiteCell = (ConduiteTableCellView *)cell;
        for (UIView *view in conduiteCell.textView.subviews)
        {
            if ([view isKindOfClass:[UIImageView class]])
            {
                if (view.alpha == 0 && view.frame.size.width < 10)
                {
                    view.alpha = 1;
                    break;
                }
            }
        }
        [conduiteCell.textView flashScrollIndicators];
    }
}

But after the [self.tableView reloadData]; nothing happens. What am I doing wrong? Shall I place my code in some other method?

Upvotes: 1

Views: 607

Answers (1)

trungduc
trungduc

Reputation: 12144

Remove [conduiteCell.textView flashScrollIndicators]; and it will work.

-(void)tableView:(UITableView *)tableView didEndDisplayingCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
  if (cell.class == [ConduiteTableCellView class])
  {
    ConduiteTableCellView *conduiteCell = (ConduiteTableCellView *)cell;
    for (UIView *view in conduiteCell.textView.subviews)
    {
      if ([view isKindOfClass:[UIImageView class]])
      {
        if (view.alpha == 0 && view.frame.size.width < 10)
        {
          view.alpha = 1;
          break;
        }
      }
    }
  }
}

Upvotes: 1

Related Questions