I have a UIScrollView with a very large content view, it's a bookshelf with around 1000 items on it, when the scroll views content becomes more than around 16000px high it shows a black background and all graphics overlap/blend together.
Here is the sample code
Code:
- (void)viewDidLoad {
[super viewDidLoad];
// Doesn't work
int sizeForContent = 20000;
// Does Work
//sizeForContent = 10000;
UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
UIView *subView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, sizeForContent)];
subView.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed: @"wood.jpg"]];
[scroll addSubview:subView];
[subView release];
scroll.contentSize = CGSizeMake(self.view.frame.size.width, sizeForContent);
[self.view addSubview:scroll];
[scroll release];
}
Does anyone know why this happens? I assume it is something to do with memory limits but it doesn't seem to be using much memory.
I know I could set the scrollview background color directly instead of adding a subview and setting the background of that but I need to leave the scrollview background as a color.
You can get the basic xcode project from
ScrollViewTest.zip if you want to see the issue.
Any help or explanations greatly appreciated.