I was trying my code on my i pad and it crashed. There is nothing on device logs but unknown type and unknown process. So i did dig. I tot it was a memory problem. What i figured out that i cannot add so many images on a horizontal scrollview. I have 100+ of them.
This is my code
for(int index=0; index < 166; index++)
{
UIImageView *imgscv = [[UIImageView alloc] init];
imgscv.bounds = CGRectMake(0, 0, 200, 250);
imgscv.frame = CGRectMake(5+xOffset, 5, 200, 250);
imgscv.image = [UIImage imageNamed:[NSString stringWithFormat:@"%d.jpg",index-1]];
[images insertObject:imgscv atIndex:index];
scrollview.contentSize = CGSizeMake(scrollWidth+xOffset,110);
[scrollview addSubview:[images objectAtIndex:index]];
xOffset += 205;
}
When i changed the upper limit of index in the for-loop to 16 everything is fine.So is that it ? Is there a limit ? Any fixes or alternatives you may suggest?
Why don’t you just load the visible part of the scrollview, and then use
responder and draw others in there after scroll. Would save a lot of performance