Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 12-03-2011, 01:01 PM   #1 (permalink)
Registered Member
 
Join Date: Dec 2011
Posts: 15
morands is on a distinguished road
Default How to position many UIImage in a UIView with a specified space

Hi,
I have a quite complex question (at least for me): I have to handle some UIImage in a UIView but I want to put all those images at a determined distance between them (it's the shelf for a magazine app). Here is the code with the images:

Code:
 self.cover = [[[UIImageView alloc] initWithFrame:CGRectMake(8, 70, 279, 410)] autorelease];
    _cover.backgroundColor=[UIColor clearColor];
    _cover.contentMode=UIViewContentModeScaleAspectFit;
I'd like to have those on 2 rows and much more ordinated.

How it looks now.

How it SHOULD look.

Here you can find the entire project, to edit it directly.

The guy who will help me fixing that will be listed in the thanks section of the app.

Thank you very much!
morands is offline   Reply With Quote
Old 12-03-2011, 01:17 PM   #2 (permalink)
Just helping out.
 
Domele's Avatar
 
Join Date: Feb 2011
Posts: 2,565
Domele is on a distinguished road
Default

Define the spacing on the left and right, the spacing on the very top and bottom, and the space between two vertical images. Enumerate through your images, determine if the image number is odd or even. If odd, it's an image on the left. If it's even, it's an image on the right. For the x position, use totalWidth - spacing on the right - width of image. For every 2 images, you go through, add 1 to an int called row that initially starts at 1. For the y, multiply the row by the vertical spacing and then add the very top spacing.
__________________
If you are looking for a quality developer, I'm your man. Give me a PM if you are interested.

New app - See screenshots and details at www.globaclock.com.

If you want to thank me, click the link. Every click counts. If you want to do more, buy my app. A link is available on my website. Thanks.
Domele is offline   Reply With Quote
Old 12-03-2011, 01:27 PM   #3 (permalink)
Registered Member
 
Join Date: Dec 2011
Posts: 15
morands is on a distinguished road
Default

Thanks for the reply but I haven't understood very well: what did you mean with
Quote:
For all the other images, determine if the image number is odd or even
how can i determinate if an image is odd or even?!? Could you explain me what you mean in code, because I'm pretty new with obj-c? Thanks again!!!
morands is offline   Reply With Quote
Old 12-03-2011, 01:29 PM   #4 (permalink)
Just helping out.
 
Domele's Avatar
 
Join Date: Feb 2011
Posts: 2,565
Domele is on a distinguished road
Default

Well if your images are in an array, they have an index number. And now that I think about, you'd have to add 1 to index for my method to work. To check if this index number is odd or even you'd use %. The result will be the remainder of the division. So if x divided by 2 has a remainder, we know it's odd, if it doesn't, it's even.
Code:
if (x % 2 == 0) {
//x is even
}
else {
//x is odd
}
__________________
If you are looking for a quality developer, I'm your man. Give me a PM if you are interested.

New app - See screenshots and details at www.globaclock.com.

If you want to thank me, click the link. Every click counts. If you want to do more, buy my app. A link is available on my website. Thanks.
Domele is offline   Reply With Quote
Old 12-03-2011, 01:36 PM   #5 (permalink)
Registered Member
 
Join Date: Dec 2011
Posts: 15
morands is on a distinguished road
Default

ah ok, but I'm not using an array: I have a .plist file on the web and in every item there's the url for the image to display, because in the final project the covers will be uploaded online every month. So the only code that I use is the one in the first post... I have never used an array, do I need to use one in this project? Thank you again
morands is offline   Reply With Quote
Old 12-03-2011, 01:40 PM   #6 (permalink)
Just helping out.
 
Domele's Avatar
 
Join Date: Feb 2011
Posts: 2,565
Domele is on a distinguished road
Default

Well the plist is probably an array so you just have to load it from memory. First you'll have to get the file path using NSBundle
Code:
pathForResource:ofType:
Then use NSArray's
Code:
initWithContentsOfFile:
method.
__________________
If you are looking for a quality developer, I'm your man. Give me a PM if you are interested.

New app - See screenshots and details at www.globaclock.com.

If you want to thank me, click the link. Every click counts. If you want to do more, buy my app. A link is available on my website. Thanks.
Domele is offline   Reply With Quote
Old 12-03-2011, 02:13 PM   #7 (permalink)
Registered Member
 
Join Date: Dec 2011
Posts: 15
morands is on a distinguished road
Default

ok, I looked my plist a bit deeper and it's an array and every item is called "dict". but, to be honest, I haven't understood mostly of what you said: HOW and where to use the array's method?

couldn't you take a look to my project I'm sure that it's very easy for you, but I'm new with all this stuff and I'm really lost!
morands is offline   Reply With Quote
Old 12-03-2011, 02:17 PM   #8 (permalink)
Just helping out.
 
Domele's Avatar
 
Join Date: Feb 2011
Posts: 2,565
Domele is on a distinguished road
Default

Sorry, but I'm not going to look at your project unless I'm getting paid. You'd probably create the array of images from your plist in viewDidLoad. But you'll have to implement lazy loading. Cocanetics has a UIImageView subclass for that: And Now Lazy Loading with NSURLConnection | Cocoanetics
__________________
If you are looking for a quality developer, I'm your man. Give me a PM if you are interested.

New app - See screenshots and details at www.globaclock.com.

If you want to thank me, click the link. Every click counts. If you want to do more, buy my app. A link is available on my website. Thanks.
Domele is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 400
14 members and 386 guests
7twenty7, AppsBlogger, Clouds, David-T, Duncan C, EvilElf, HemiMG, heshiming, iekei, LunarMoon, Murphy, sacha1996, Sami Gh, teebee74
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,676
Threads: 94,127
Posts: 402,915
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jleannex55
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 06:44 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0