How do you return draggable content to their original positions in iPhone dev? - iphone

I am wanting to create a button in my iPhone app that when touched will return other draggable elements to their original position. I have looked at the Apple "MoveMe' example, but that returns the button to the center of the screen. I want to be able to position draggable objects around the screen, drag the objects within the app, and then return them to their original starting positions by pressing a designated button.
Any help appreciated!

Cache the initial positions of your draggable objects, and use an event handler on the button to reset their positions. I'm a little confused. The MoveMe example code is exactly what you need to answer your question -- what more do you want? You won't find a perfect code example for any arbitrary problem you can dream up.

Play around with saving the original positions and using MoveMe to reset the objects and I bet you'll have what your looking for in no time at all.

Related

Delete button for object - MRTK

I have a question regarding Unity and mrtk. I need to create an object, which can be deleted via button push. This button should be attached to the object. Now there is the app bar which can be attached to the object and which is very convenient because the buttons are only displayed on the side of the object you currently look at. However the app bar does not seem to work properly with the new bounding box and after deactivating the adjust button on it. So my question basically is, how do i make a button which is attached to the object, hovers on it and is only displayed on the side of the object i am currently looking at? The script of the app bar is very poorly commented, so i cannot figure out which part is responsible for making the button appear on the correct side and correspondingly how to write a script displaying the delete button only on the correct side (following the direction i am currently looking at).
To solve this problem you need a free Canvas that attaches to your object. This Canvas should be adjusted to the dimensions of the object and always look at the camera. To do this, first create a canvas and set RenderMode to World Space, Remember that you have entered the Event camera reference.:
After completing the canvas, make a button like the one below and place it in the body. In this section, adjust the dimensions so that you want to appear in near of your main object.
Finally, I suggest using Look At Constraint to match the canvas and the view to the camera. Insert the camera as source and fix Constraint settings it as shown below.
Example Result

ScrollView Level Menu on Unity

I'm trying to create a ScrollView with inside images, the images are the levels in the game, and when the user choose a level(a image), he can click the button (like "PLAY") so doing that change the scene to the level selected.
And another thig...how i can do to the images still in the center of the scroll view?
I think you are asking for how to do a scrollable list, covered in this tutorial.
Instead of putting buttons in it, you put your images in.
To detect clicks on the image, you add a script to your image containing the OnClick() method. (somthing like this)
I hope I could help you.
Maybe try to put little more effort in your research before asking questions.
I will remove this Question, because i found how to do it...
Btw for the second question, i just create a script which i can make move to the center all the images/buttons/objects. And if you don't know why i'm doing this, it's for create like an animation to show much easier what button/object are you selecting..if you see an image return to the center of the scrollview, you will know that is your image.
I know... I don't, explain well what i want..but i'm new in this world of programming..

Using PageControl?

I have an array and lets say I have 5 objects in it. The array just contains a string with an address to a picture. I would like to use the Page Control feature in the iPhone SDK to swipe Left and Right to change the picture. I already have the multitouch gestures in place all I need is to implement the Page Control so if I swipe left and then right it will take me back to the previous image.
Does anyone know of any good Page Control tutorials or sample code online that may be able to help me thought implementing the Page Control.
The UIPageControl isn't a control as much as it's just an indication of what "page" your on.
To do what you want, you need to set up a UIScrollView and add subviews for each image. It will require some math to figure out where each "page" starts and ends based on image dimensions and screen sizes.
Apple has some docs on using scroll views with page controls here.
Indeed, you need a UIScrollView along with the UIPageControl. You can find a good tutorial on how to make them work together here

iphone image carousel

I hardly know how to explain my case other than to point to the excellent Absolute vodka app, Drink Spiration.
I am trying to make a carousel like image browsing with a little spice. I would really like to find a simple core animation explanation on how to accomplish something like the above app.
I hope someone can help with this. The solution doesn't have to be exactly the same, but just explain what is happening and it would be best if it was simple and no opengl. Just something to point me in the right direction. I don't think using just a scrollview with uiimageviews is enough.
I wrote something similar and its quite easy once you figure it out in your mind. All done justing using regular old views and animating transforms on them.
Say its 3 images on screen, and you can rotate new ones on and off ... then you will need 5 views set up (most simply just a UIImageView with a relevant image set). They are the currently selected image, the two either side of it and the ones that are, or will be animating on or off when the user flicks left or right.
Each of these 5 images has a position, an angle and an image. When the user flicks left or right each gets animated to the next position and angle, views that are about to come onscreen have their image updated to the next image in the set. If the user keeps on flicking in the same direction you simply reposition views on one side as they come off the other.
With this setup you can do lots of cool carousel like things very simply.

Radio dial type functionality as seen on Where To? App

Straight forward question. I'm trying to understand UI design more and how to make it work with code. In particular there used to be an app that went through several design sessions, named Where To? by Tap Tap Tap. They had a table which they turned into a radio dial, screenshot:
(source: taptaptap.com)
My question is, is this nothing more than 22 or so images, with different states put together on top of a UIView? Each UIImageView is a button? How would something like this be put together? I'd love a tutorial on programmatically turning images into actual actions. If there's any book or blog which describes the process, that would be an ideal answer for me.
Any insight into how the above is done?
I actually think it's a single image that has it's layer rotated in response to touch events and then calculates which is the active button based on the radial distance from the original position. It's not horribly complicated code (touchset change is left or right and rotate in response to that, modify the hittest method to respect the radial deltas) but the math is more than I can do before six cups of coffee.