I have a couple images that I am adding to a UIScrollView that are 320w * 180h, some nice letter boxed photos. The photos get added and everything looks good but it won't scroll.
in my viewDidLoad I have this code
To test this so far I added a couple of images to an NSMutableArray. I can see that it returns the images and I can offset the images horizontally to see that they are both there. For some reason it won't scroll.
in my viewDidLoad I have this code
Code:
[self.view addSubview:[self scrollViewPhotos]];
To test this so far I added a couple of images to an NSMutableArray. I can see that it returns the images and I can offset the images horizontally to see that they are both there. For some reason it won't scroll.
Code:
-(UIScrollView *)scrollViewPhotos{
int numOfImages, imageYsize;
numOfImages = 2;
imageYsize = 320;
NSMutableArray *imagesArray = [[NSMutableArray alloc] init];
UIImage *image1= [UIImage imageNamed:@"food_one_small.jpg"];
UIImage *image2= [UIImage imageNamed:@"food_two_small.jpg"];
[imagesArray addObject:image1];
[imagesArray addObject:image2];
UIScrollView *clientPhotos = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 200, 640, 180)];
clientPhotos.pagingEnabled = YES;
for (int i = 0; i < numOfImages; i++) {
CGFloat imageStartPoint = imageYsize * i;
UIImageView *itemToAdd = [[UIImageView alloc] initWithFrame:CGRectMake(imageStartPoint, 0, 320, 180)];
itemToAdd.image = [imagesArray objectAtIndex:i];
[clientPhotos addSubview: itemToAdd];
}
return clientPhotos;
}