1

I'm loading my Feed Data(feedArray) in UIScrollView, i'm loading 10-10 records in the Scrollview at once.

Step 1: First i get 10 records into my feedArray from my webservice.

step 2: now i'm loading the 10 records with in the UIScrollView , it's perfectly fine now.

Step 3: now when i call the webservice again, i'm getting another 10 records, now i added them onto feedArray again, feedArray count is 20 records now. and UIScrollView For loop runs for 20 times

Step 4: Like that i will call the webservice number of times, every time feedArray will be increment by 10 records.

Result: after Loading number of subviews in scrollview, when it reaches to 250 records, my scrollview is getting stuck and very slow scrolling and finally crashed in all ios devices.

because of overloading the subviews in UIScrollView caused all of this issues, so i need to over come these issues.

NOTE: i am loading 19 types of feeds in my scrollview, each feed contains number of subviews, each feed is a UIView with number of subviews.

Any help will greatly Appreciate.

Thank you guys.

Krishna1251
  • 177
  • 1
  • 10

4 Answers4

1

My guess is you should be using a UITableView. The reason your scroll view is slowing down is because it is having trouble animating all the different subviews. UITableViews handle this by hiding views that are not visible.

More information https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITableView_Class/

TheSD
  • 873
  • 5
  • 17
1

Use of UITableView and UICollectionView is recommended here.
As both of these have a mechanism of cell reuse, it will not affect the runtime memory of the app.

shoan
  • 1,303
  • 15
  • 22
0

Why not use UICollectionView and UICollectionViewController classes? UICollectionViewController reference Here

Rohit suvagiya
  • 1,005
  • 2
  • 12
  • 40
0

Logically you can do this as follows but This is too expensive operation. To solve your problem i recommend UICollectionView any way check the code for scrollview(Not Recommended).

CGRect intersectRect= CGRectMake(0,scrollView.contentOffset.y,scrollView.frame.size.width, scrollView.frame.size.height);

for (UIView *subview in scrollView.subviews )
{
    if (CGRectIntersectsRect(intersectRect, subview.frame)) // checking for intersection
    {
        // views in this condition are visible 
    }

    else
    {
        // views in this condition are invisible
    }
}

Put this code in one method and call the method in scrollview delegate method scrollViewDidEndDecelerating:

hope it helps

Smile
  • 667
  • 1
  • 5
  • 21