这是示例代码 -(void)viewDidLoad {[super viewDidLoad];//无效int sizeForContent = 20000;//可以工作//sizeForContent = 10000;UIScrollView * scroll = [[UIScrollView分配] initWithFrame:CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height)];UIView * subView = [[UIView分配] initWithFrame:CGRectMake(0,0,self.view.frame.size.width,sizeForContent)];subView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"wood.jpg"]];[scroll addSubview:subView];[subView版本];scroll.contentSize = CGSizeMake(self.view.frame.size.width,sizeForContent);[self.view addSubview:scroll];[滚动发布];} 有人知道为什么会这样吗?我认为这与内存限制有关,但似乎并没有占用太多内存.我知道我可以直接设置scrollview背景颜色,而无需添加子视图并设置其背景,但是我需要将scrollview背景保留为颜色.如果想查看,可以从 http://cl.ly/2i3F3q0G1j3q433n0f1E 中获得基本的xcode项目问题.任何帮助或解释都将不胜感激.解决方案我通过创建具有图案背景的视图并将滚动视图添加为具有 [UIColor clearColor] 背景的子视图来解决此问题.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- (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 http://cl.ly/2i3F3q0G1j3q433n0f1E if you want to see the issue.Any help or explanations greatly appreciated. 解决方案 I solved it by creating view with pattern background, and adding scroll view as subview with [UIColor clearColor] background. 这篇关于具有背景图案的大型UIScrollView失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 07-24 18:37