私のアプリでは、メモリの問題で少し問題があります。
私のコーディングスキルは完璧には不十分です。
私のコードは、本当に必要なメモリを4回使用します。
コーディングを変更するにはどうすればよいですか?
私のコードは
-(void)viewDidAppear:(BOOL)animated
{
UIScrollView * ScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 44, self.view.frame.size.width, self.view.frame.size.height-88)];// 44(UpperNavigtionBar),-88(Upper+Lower)
ScrollView.pagingEnabled = YES;
// Create a UIImage to hold Info.png
UIImage *image1 = [UIImage imageNamed:@"Image-001.jpg"];
UIImage *image2 = [UIImage imageNamed:@"Image-002.jpg"];
UIImage *image3 = [UIImage imageNamed:@"Image-003.jpg"];
UIImage *image4 = [UIImage imageNamed:@"Image-004.jpg"];
UIImage *image5 = [UIImage imageNamed:@"Image-005.jpg"];
UIImage *image6 = [UIImage imageNamed:@"Image-006.jpg"];
UIImage *image7 = [UIImage imageNamed:@"Image-007.jpg"];
UIImage *image8 = [UIImage imageNamed:@"Image-008.jpg"];
UIImage *image9 = [UIImage imageNamed:@"Image-009.jpg"];
UIImage *image10 = [UIImage imageNamed:@"Image-010.jpg"];
UIImage *image11 = [UIImage imageNamed:@"Image-011.jpg"];
UIImage *image12 = [UIImage imageNamed:@"Image-012.jpg"];
UIImage *image13 = [UIImage imageNamed:@"Image-013.jpg"];
NSArray *images = [[NSArray alloc] initWithObjects:image1,image2,image3,image4,image5,image6,image7,image8,image9,image10,image11,image12,image13,nil];
NSInteger numberOfViews = 13;
for (int i = 0; i < numberOfViews; i++)
{
CGFloat xOrigin = i * self.view.frame.size.width;
UIImageView * ImageView = [[UIImageView alloc] initWithFrame:CGRectMake(xOrigin, 0, self.view.frame.size.width, self.view.frame.size.height-88)]; // -88(Upper+Lower)
[ImageView setImage:[images objectAtIndex:i]];
[ScrollView addSubview:ImageView];
}
ScrollView.contentSize = CGSizeMake(self.view.frame.size.width*numberOfViews, self.view.frame.size.height-88); // -88(for adding Image View as subview)
[self.view addSubview:ScrollView];
}