Hello guys,
How can create a view with mutiple images, something similiar to the photo app on the iphone?
THanks
Hello guys,
How can create a view with mutiple images, something similiar to the photo app on the iphone?
THanks
My standard answer: check out the TTPhotoViewController
in the Three20 project:
TTPhotoViewController emulates Apple's Photos app with all of its flick n' pinch delight. You can supply your own "photo sources", which works similiarly to the data sources used by UITableView. Unlike Apple's Photos app, it isn't limited to photos stored locally. Your photos can be loaded from the network, and long lists of photos can be loaded incrementally.
So if you want a 4 by 4 grid of pictures (that are 20x20) each for example, you can use a scroll view and add UIImageViews to it something like
UIScrollView *s= [[UIScrollView alloc] initWithFrame:someFrame]
int position x=10;
int position y=10;
for(int i=1; i<=pictures.count; i++)
{
UIImageView *image= [[UIImageView alloc] initWithFrame:CGRectMake(x,y,20,20)]
image.image=[UIImage imageNamed:..] //initialize the image for the view
[s addSubview:image];
if(i%4==0) //means you need to start a new row
{
y+=20; //you can tweak this to make it look how you like
x=10; //come back to the beggining
}
else
x+=10; //again tweak this to make it "look" right
}
Dear Daniel, You'd be better to release image instance after adding.