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 03-30-2011, 08:04 AM   #1 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 25
BarryK88 is on a distinguished road
Default Save the position (CGPoints) of a image.

I'm trying to save the positions of several images whom are inside my view. How can i store the coordinates of the images so that when the App launches the images are still at the same location?

Thanks in advance!
BarryK88 is offline   Reply With Quote
Old 03-30-2011, 09:28 AM   #2 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 24
Posts: 3,983
smithdale87 is on a distinguished road
Send a message via AIM to smithdale87
Default

How many images locations are you trying to save?

If not many, you can use NSUserDefaults to save each individual point. You'll want to first convert the point to an NSString using NSStringFromCGPoint( thePoint ). And later, when you read the string from NSUserDefaults, there is a corresponding method to convert a string back to a CGPoint.

If you are saving a lot of points, it will probably be easier to do what is described above, but add each of the strings to an NSArray and then save the array to NSUserDefaults.
smithdale87 is offline   Reply With Quote
Old 03-30-2011, 09:54 AM   #3 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 25
BarryK88 is on a distinguished road
Default

I got 20 images in total. Still got no clue about the next thinking steps.

Help is greatly appreciated!
BarryK88 is offline   Reply With Quote
Old 03-30-2011, 11:51 AM   #4 (permalink)
Reading the Documentation
 
baja_yu's Avatar
 
Join Date: Sep 2010
Location: 45.255019,19.844908
Posts: 5,414
baja_yu has a spectacular aura about
Default

Are we talking about ImageViews or UIImages, because the latter don't have position, they're just images. If you have image views then you can save the value pairs of .frame.origin.x and .frame.origin.y, then reload on launch and restore the position.
baja_yu is offline   Reply With Quote
Old 03-30-2011, 12:55 PM   #5 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 25
BarryK88 is on a distinguished road
Default

We are talking about 20 UIImageViews. I placed them within my viewDidLoad method like:

image1.center = CGPointMake(381, 637);
etc.

A user is able to drag is UIImageView by means of the touchesmethod, so the coordinates change after dragging. I'd like to save those new coordinates of the UIImageViews.

Any suggestions?
BarryK88 is offline   Reply With Quote
Old 03-31-2011, 03:28 AM   #6 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

you can use NSDictionary or NSArray to collect your coordinates and then NSUserDefault to store that dictionary/array and retrieve it.

ps: you need to use NSNumber (or NSValue) to save your coordinates (that are primitives) to an dictionary/array (that is an object).
__________________

Last edited by dany_dev; 03-31-2011 at 03:33 AM.
dany_dev is offline   Reply With Quote
Old 01-18-2012, 10:14 AM   #7 (permalink)
Registered Member
 
Join Date: Jan 2012
Posts: 1
timmyc10 is on a distinguished road
Cool Any luck with this

Quote:
Originally Posted by dany_dev View Post
you can use NSDictionary or NSArray to collect your coordinates and then NSUserDefault to store that dictionary/array and retrieve it.

ps: you need to use NSNumber (or NSValue) to save your coordinates (that are primitives) to an dictionary/array (that is an object).
Any luck with this?
timmyc10 is offline   Reply With Quote
Reply

Bookmarks

Tags
cgpoint, coordinates, image, save

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: 366
12 members and 354 guests
condor304, dansparrow, dre, ilmman, LezB44, michelle, Objective Zero, samdanielblr, Sami Gh, shagor012, thephotographer, tinamm64
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,663
Threads: 94,119
Posts: 402,896
Top Poster: BrianSlick (7,990)
Welcome to our newest member, LezB44
Powered by vBadvanced CMPS v3.1.0

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