Please do not post the same thing multiple times. The board software automatically flags certain posts as needing moderator attention. This happens the most often for new users. I'm pretty sure this is made clear at the time you attempt to post. Posting the same thing over and over again just makes that many more posts the moderators have to weed through later. This makes us sad. Don't make us sad. If your post/thread doesn't appear, just wait a while. Don't post it again. If it hasn't shown up by the next day, then you can try again. I normally go through posts in the mornings, and try to check a few times throughout the day, but I'm not here 24/7. There will typically be a significant delay before posts are approved. Just be patient.
how to move a view from where you touch it on the view?
Ok what i have working are views the user can move about the screen. In my touches moved code i am moving the view about it center. Ultimately what i would want to do is be able to move the view at whichever point the user touches the view on. Any more details just ask but i think thats good enough
When it is first touched, make a note of how far away the touch is from the view center. When adjusting the center, include that adjustment in the calculation.
One of the WWDC videos from last year, I believe it focused on scroll views, shows an example.
When it is first touched, make a note of how far away the touch is from the view center. When adjusting the center, include that adjustment in the calculation.
One of the WWDC videos from last year, I believe it focused on scroll views, shows an example.
Or note the original center, and the original touch point for the touchesBegan. When the user drags their finger, move the view's center by the same offset.
Gesture recognizers make this easier. Do a search in "Touches" in the Xcode help system, and look under Sample code for an entry with that name. It is a sample project that shows exactly how to do this. Note that there are actually 2 versions of the project, one that uses touchesBegan/touchesMoved/touchesEnded, and one that uses a pan gesture recognizer. I suggest looking at the gesture recognizer version. The code is much cleaner and easier to maintain.
Regards,
Duncan C WareTo
Animated GIF created with Face Dancer, available for free in the app store.
Well i already have code i am using in TouchesMoved ect. so imma try to stick with that. I checked the Touches app and the code using TouchesMOved only moves the view about the center and not the initial touch point. Ill give your ideas with what to do with the initial point and center of the object and if i can't figure it out ill go with the UIPanGesture method instead. Thanks to both of you
Code in a release app would need range checking to provent the user from dragging the view completely off the screen.
Good point, my code does that already since if the user lifts their finger off the view the view automatically disappears but its good for whomever will read this to know they must remove the view somehow
Replies
One of the WWDC videos from last year, I believe it focused on scroll views, shows an example.
BriTer Ideas LLC - WWW | Facebook | Twitter - Professional iOS App Development. Available for hire.
SlickShopper 2 | BTIConcepts on GitHub | Free NSLog utility | Free Getter Utility | Leave a PayPal donation.
Are you a newbie? Things you should read:
Definitive Guide To Properties | UITableView Series | A Model (Object) Is A Beautiful Thing
- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like AwesomeGesture recognizers make this easier. Do a search in "Touches" in the Xcode help system, and look under Sample code for an entry with that name. It is a sample project that shows exactly how to do this. Note that there are actually 2 versions of the project, one that uses touchesBegan/touchesMoved/touchesEnded, and one that uses a pan gesture recognizer. I suggest looking at the gesture recognizer version. The code is much cleaner and easier to maintain.
Duncan C
WareTo
Animated GIF created with Face Dancer, available for free in the app store.
- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like Awesomein your touchesBegan method just take the offset of the view in relation to the point of touch and the center
Then in touches moved just set the center of the view to the touchLocation minus the center
- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like AwesomeCode in a release app would need range checking to provent the user from dragging the view completely off the screen.
Duncan C
WareTo
Animated GIF created with Face Dancer, available for free in the app store.
- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like Awesome- Spam
- Abuse
- Troll
0 · Off Topic Insightful Disagree Dislike Like Awesome