I have a large amount of image buttons being added to the screen in an iPhone app. Everything is working fine with my code.
The problem is the subviews are not displaying until every one of the subviews are ready to display. So for example I have 48 subviews, I don't want to wait until every subview is ready, I want to visibly be able to see each one appearing on the screen as they are loading.
I hope this makes sense. The issue is getting larger as i add more images to the collection.
This is my code for you to see:
for (int i = 0; i < imgNumbers.count; i++) {
myButton = [UIButton buttonWithType:UIButtonTypeCustom];
CGRect buttonValue = [[btn9Locations objectAtIndex:location] CGRectValue];
myButton.frame = buttonValue;
NSString *imagePart1 = [[NSString alloc] initWithFormat:@"%@", imgNumbers[i]];
[myButton addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchDownRepeat];
NSURL *tmpDirURL = [NSURL fileURLWithPath:NSTemporaryDirectory() isDirectory:YES];
NSURL *fileURL = [tmpDirURL URLByAppendingPathComponent:imagePart1];
NSString *imageLocation = [[NSString alloc]initWithFormat:@"%@", [fileURL path]];
UIImage * image = [UIImage imageWithContentsOfFile:imageLocation];
[myButton setBackgroundColor:[UIColor colorWithRed:0.94 green:0.39 blue:0.13 alpha:0.0]];
[myButton setBackgroundImage:image forState:UIControlStateNormal];
[myButton setTitle:[imageNames[i] uppercaseString] forState:UIControlStateNormal];
[myButton.titleLabel setFont:[UIFont fontWithName:@"Helvetica-Light" size:20]];
[myButton setContentHorizontalAlignment:UIControlContentHorizontalAlignmentRight];
[myButton setContentVerticalAlignment:UIControlContentVerticalAlignmentBottom];
[myButton setTitleColor:[UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.5] forState:UIControlStateNormal];
myButton.imageView.layer.cornerRadius = 7.0f;
myButton.layer.shadowRadius = 3.0f;
myButton.layer.shadowColor = [UIColor blackColor].CGColor;
myButton.layer.shadowOffset = CGSizeMake(0.0f, 1.0f);
myButton.layer.shadowOpacity = 0.5f;
myButton.layer.masksToBounds = NO;
[buttons addObject:myButton];
[scrollview addSubview:myButton]; }
Hope this makes sense, I have seen apps that when you scroll down each item fades onto the screen but I don't seem to be able to sort this part first!
Thanks