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 01-19-2012, 09:53 AM   #1 (permalink)
Registered Member
 
Join Date: Feb 2011
Posts: 11
kpearce2 is on a distinguished road
Default Drawing Lines as objects

Hi,

I'm struggling with this. I have created an app that allows the user to draw to the screen with their finger. simple. What I want to be able to do is allow the user to select that line and move it if they wished to. How would I go about giving this line a reference so that it can be called? I currently have the lines being drawn to a uiimage - maybe that isn't the best way to go about it.

Thanks for any help.
kpearce2 is offline   Reply With Quote
Old 01-19-2012, 12:45 PM   #2 (permalink)
Cocoa Junkie
 
Duncan C's Avatar
 
Join Date: Dec 2008
Location: Northern Virginia
Posts: 6,003
Duncan C has a spectacular aura about
Default

Quote:
Originally Posted by kpearce2 View Post
Hi,

I'm struggling with this. I have created an app that allows the user to draw to the screen with their finger. simple. What I want to be able to do is allow the user to select that line and move it if they wished to. How would I go about giving this line a reference so that it can be called? I currently have the lines being drawn to a uiimage - maybe that isn't the best way to go about it.

Thanks for any help.


The easiest thing to do would be to make each line be it's own UIImage object. Then you could add a gesture recognizer to it and the user could drag it around.

If you've got 100 or less, do that. If you're creating more than that, you need another approach, because views are fairly large and complex, and you run the risk of running out of memory, or at least bogging down drawing as all those overlapping lines have to be drawn.

Alternately, you could create a custom subclass of UIView that manages an array of line objects, and asks each of them to draw itself. You could make the line objects be NSObjects, not views. They would use the drawing context of the view they belong to, and would be called on to draw themselves from the enclosing view's drawRect method. To do that, you'd have to write some rather complex code in your custom view that hit tests the different line objects to figure out which one the user is dragging, and asks it to update itself while the user is dragging it around.
__________________
Regards,

Duncan C
WareTo

Check out our apps in the Apple App store


Check out this password generator app that shows various techniques including using a data container singleton object to share data between objects in your project.

See this tutorial on using UIView animations and layer animations:

See this thread on generating random, non-repeating text

Check out a very cool Macintosh Kaleidoscopes app called ScopeWorks that we released to the Mac App store.
Duncan C is offline   Reply With Quote
Reply

Bookmarks

Tags
drawing, referencing, touch

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
9 members and 391 guests
7twenty7, Atatator, glenn_sayers, guusleijsten, iphonedevshani, QuantumDoja, Sami Gh, tim0504, VinceYuan
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,674
Threads: 94,122
Posts: 402,907
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Atatator
Powered by vBadvanced CMPS v3.1.0

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