0

I have UIScrollView with a lot of rows (~100) and I implemented dequeueReusableRow method for fast allocating and adding my subviews (rows). Everything work fine, but if I scroll very fast with decelerate some view don't added to scrollView on time only later.

- (UIView *)dequeueReusableRow
{
    UIView *view = [reusableRows anyObject];

    if(view) 
    {
        [[view retain] autorelease];
        [reusableRows removeObject:view];
    }else{
        view = [[UIView alloc] init....
    }

    return view;
}

- (void)addVisibleRows
{
    UIView *row = [self dequeueReusableRow];
    row.frame = ....
    [scrollView addSubview:row]
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    [self addVisibleRows];
    [self removeInvisibleRows];
}

Please, don't propose me use UITableView because structure of accordion looks like:

section
- section
-- section
--- row
- section
section
- row
tikhop
  • 2,012
  • 14
  • 32
  • I propose you use UITableView. http://stackoverflow.com/questions/1944428/how-to-implement-an-accordion-view-for-an-iphone-sdk-app – jrturton Jul 03 '12 at 09:19

2 Answers2

1

dequeueReusableRow is not part of UIScrollViewController, so I assume dequeueReusableRow is something you implemented yourself. If so, can you show that code? It is likely where we can help with any inefficiencies.

Also, if your scrollview contains rows, why not just use a UITableView which will do much of the work for you? I know you asked not to propose it - can you explain why you need to use a ScrollView so we can help you better?

Aaron Brager
  • 65,323
  • 19
  • 161
  • 287
0

It's very hard to tell from that code snippet. Some more details would be appreciated.

One minor suggestion in the meantime: Call removeInvisibleRows before addVisibleRows

Adrian Schönig
  • 1,786
  • 18
  • 26