BTMExpert
asked on
photo gallery
is there a way to have photos display just like a camera roll but use the photos from a folder instead of the pictures from my library?
ASKER
thank you for the response but i need something for the iphone. The iphone camera roll shows pictures in a tiled or grid view. I want to know how you do that but instead of using images from the camera library, use pictures from a folder I'm creating.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
i think i'm trying that with this:
scrollView = [[UIScrollView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
//scrollView.delegate = self;
scrollView.bouncesZoom = YES;
scrollView.backgroundColor = [UIColor blackColor];
containerView = [[UIView alloc] initWithFrame:CGRectZero];
[scrollView addSubview:containerView];
CGFloat maximumWidth = 0.0;
CGFloat totalHeight = 0.0;
CGFloat totalWidth = 0.0;
for(int i = 1; i <= 11; i++) {
UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"%d.png" , i]];
if(totalWidth > 320) {
totalWidth = 0;
}
CGRect frame = CGRectMake(totalWidth, totalHeight, image.size.width - 30, image.size.height - 30);
UIImageView *imageView = [[UIImageView alloc] initWithFrame:frame];
imageView.image = image;
[containerView addSubview:imageView];
[imageView release];
maximumWidth = MAX(maximumWidth, image.size.width);
totalHeight += image.size.height;
totalWidth += image.size.width;
}
containerView.frame = CGRectMake(0, 0, 320, totalHeight);
scrollView.contentSize = containerView.frame.size;
but my images don't go side by side or in a grid for that matter. am i missing something in the frame loop?
scrollView = [[UIScrollView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
//scrollView.delegate = self;
scrollView.bouncesZoom = YES;
scrollView.backgroundColor
containerView = [[UIView alloc] initWithFrame:CGRectZero];
[scrollView addSubview:containerView];
CGFloat maximumWidth = 0.0;
CGFloat totalHeight = 0.0;
CGFloat totalWidth = 0.0;
for(int i = 1; i <= 11; i++) {
UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"%d.png"
if(totalWidth > 320) {
totalWidth = 0;
}
CGRect frame = CGRectMake(totalWidth, totalHeight, image.size.width - 30, image.size.height - 30);
UIImageView *imageView = [[UIImageView alloc] initWithFrame:frame];
imageView.image = image;
[containerView addSubview:imageView];
[imageView release];
maximumWidth = MAX(maximumWidth, image.size.width);
totalHeight += image.size.height;
totalWidth += image.size.width;
}
containerView.frame = CGRectMake(0, 0, 320, totalHeight);
scrollView.contentSize = containerView.frame.size;
but my images don't go side by side or in a grid for that matter. am i missing something in the frame loop?
I'd say it's a wrong calculation. I can be wrong I do not know what you want.
Pay attention on these lines:
CGRect frame = CGRectMake(totalWidth, totalHeight, image.size.width - 30, image.size.height - 30);
and
maximumWidth = MAX(maximumWidth, image.size.width);
totalHeight += image.size.height;
totalWidth += image.size.width;
This code is supposed to do what? Can you explain?
Pay attention on these lines:
CGRect frame = CGRectMake(totalWidth, totalHeight, image.size.width - 30, image.size.height - 30);
and
maximumWidth = MAX(maximumWidth, image.size.width);
totalHeight += image.size.height;
totalWidth += image.size.width;
This code is supposed to do what? Can you explain?
ASKER
it places the image on the view inside the frame. the totalwidth and totalheight are the position of the frames and the image sizes are the sizes of the frame. so i'm trying to put them side by side so i keep adding the width of each image so i can get the position of the next image. but maybe i'm missing something or maybe there's an easier way.
On Mac OS X you can use Image Kit.
http://www.macresearch.org/cocoa-tutorial-image-kit-and-image-browser-views-part-i
It looks better and works faster. I do not know if exists something like that for iPhone.
http://www.macresearch.org/cocoa-tutorial-image-kit-and-image-browser-views-part-i
It looks better and works faster. I do not know if exists something like that for iPhone.
there are third party tools who let you view pictures from folders (insteas of from you iPhoto Library), check out xee (http://wakaba.c3.cx/s/apps/xee.html) or CocoViewX( http://www.stalkingwolf.net/software/cocoviewx/)