我有一个数组,其中的图像显示在scrollView中。它在模拟器上运行得很好但是当我在实际设备(第一代iPad)上运行它时会崩溃。起初我将图像的质量降低到最低(每个<120kb),但这并没有解决我的问题。然后我将图像数量从13减少到6并且它可以工作。你能想到什么工作吗? 以下是我使用的代码:
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
images = [NSArray arrayWithObjects:[UIImage imageNamed:@"back1.jpg"], [UIImage imageNamed:@"back2.jpg"], [UIImage imageNamed:@"back3.jpg"], [UIImage imageNamed:@"back4.jpg"], [UIImage imageNamed:@"back5.jpg"], [UIImage imageNamed:@"back6.jpg"], [UIImage imageNamed:@"back7.jpg"], [UIImage imageNamed:@"back8.jpg"],[UIImage imageNamed:@"back9.jpg"],[UIImage imageNamed:@"back10.jpg"],[UIImage imageNamed:@"back11.jpg"],[UIImage imageNamed:@"back12.jpg"],[UIImage imageNamed:@"back13.jpg"], nil];
pageControl.numberOfPages=images.count;
for (int i = 0; i < images.count; i++) {
CGRect frame;
frame.origin.x = self.scrollView.frame.size.width * i;
frame.origin.y = 0;
frame.size = self.scrollView.frame.size;
subview = [[UIImageView alloc] initWithFrame:frame];
subview.contentMode = UIViewContentModeScaleAspectFit;
subview.image = [images objectAtIndex:i]; //problima sthn eikona
[self.scrollView addSubview:subview];
}
pageControlBeingUsed = NO;
self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width * images.count, self.scrollView.frame.size.height);}