Add subview (rows) fast to UIScrollView while scrolling

Posted by tikhop on Stack Overflow See other posts from Stack Overflow or by tikhop
Published on 2012-07-02T21:15:17Z Indexed on 2012/07/03 15:16 UTC
Read the original article Hit count: 186

Filed under:
|
|
|

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

© Stack Overflow or respective owner

Related posts about iphone

Related posts about ios