click on floor plan regions in an iPhone app? - ios

I want to build an iPhone app that displays a floor plan of different regions/rooms. When a user taps on a region/room, it shows the hit-state color for a fraction of a second before sliding to a new UIView with additional text information.
Should I be setting up all the different regions via UIImages or should I draw my own floor plans programmatically? I tried drawing some rectangles programmatically, but wasn't sure if it's possible to attach tap event handlers to the graphics. Or if it's easier to maintain floor maps with unusual shapes programmatically.

My requirement was same like you. See my Question. Finally i am go ahead with UIScrollView with Zoom in out functionality. I have add multiple UIViews in Scroll and all UIViews have UILable So it will look like Room / Booth and it will look like this Question. To archive this i have face one Query and finally resolved this and implement the Floor Map Like my 1st question link.
Now to resolved your question that You have to implement UITapGestureRecognizer like below code.
UITapGestureRecognizer *fingerTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:#selector(handlefingerTap:)];
fingerTap.delegate = self;
[fingerTap setNumberOfTapsRequired:1];
than you have to set this Gesture to your view and implement the tap method like below
[rigionView addGestureRecognizer:fingerTap];
- (void)handlefingerTap:(UIGestureRecognizer *)gestureRecognizer
{}
If you have add multiple UIViews in Scroll than implement the above code in for loop.i have done the same.
I hope it will help you..

Related

How would you make a horizontal picker view in sprite kit to choose different characters?

I am trying to make a game in SWIFT (SpriteKit) where the user can pick between a large amount of characters to play as during the game. The 'characters' would be in what looks like a horizontal picker view. It is similar to the app "Ball King's" player chooser that looks like this:
and
I do not know where to start and any help would be great! Thank you!
Just set up a UISwipeGestureRecognizer in your view. When a swipe is detected, get the direction of the swipe and either display the next or previous sprite with an animation. If you haven't used gesture recognizers documentation is here. Another option is to simply detect swipes generically using touchesBegan, touchesMoved, etc.

Dragging an uiview like facebooks menu slide

I know this has been probably asked before but I've seen many approaches and i don't know which is best for me, so plz don't send me a link to another post unless it addresses my problem directly.
I have a controller which has a uiview on the top (like a header) (this header is bigger than it seems because is partially hidden on top). on that view i have a uibutton which now with a touch up inside shows the entire header view and taping again returns it to its starting position (changing frame with animation). I want to also be able to drag the view but only changing position on the y axis(dragging up and down)... i was thinking of adding the dragInside/Outside event to the button but this doesn't give me the position of the finger... and also want to know when the user releases the drag so the view ends animation to any of its two possible states (showing or partially hidden). Is this a "touches began" , "touches moved" , "touches ended" thing? if it is please provide a code example. I also want to do this with another view but this is on the left side... same thing but this one moves on the X axis... any help is appreciated. or maybe it can be made with drag event if i only can save a CGpoint of last touch, maybe that's better, any other suggestions
Look at using a UIPanGestureRecognizer to detect the touch movements. Use the translationInView: of the gesture to set the view y position. The translation is the total movement since the start of the gesture so you don't need to remember and accumulate the offset position yourself.
The main thing to worry about while implementing this is bounding the y position of the view so that no matter how far the user drags the view won't go too high or low on the screen.
Use a UIPanGestureRecognizer, that's a class dedicated to handling such drag/pan gestures.
Everything is described here in Apple's documentation, including examples, so you should find your answer here.
There is also some sample code in Apple Developer Library that shows you how to use Gesture Recognizers if needed.

Draggable ViewController like the iPhone facebook app

I'm wondering how to go about implementing a draggable viewcontroller such as that in the Facebook app where the user can drag from the far left of the screen to the right and the viewcontroller will follow, revealing another view underneath. I'm not looking to rip off this design, I just find it to be a very interesting way to display extra information and I'd like to learn more about draggable interfaces.
Now I'm somewhat familiar with UIPanGestureRecognizers but I imagine this is far more complex?
Where would I start?
I've used this with pretty good luck:
ECSlidingViewController
I did my research on all the options at the time (like a month ago) and this is most like facebooks because you can drag anywhere on the screen to move it. Also this supports both orientations
You can find solution here: How to move an UIViewController?
In that example you can drag viewControllers by swiping navigationBar
In that example FronViewController viewDidLoad method contains code:
UIPanGestureRecognizer *navigationBarPanGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self.navigationController.parentViewController action:#selector(revealGesture:)];
[self.navigationController.navigationBar addGestureRecognizer:navigationBarPanGestureRecognizer];
and ZUUIRevealController contains method to handle recognizer:
- (void)revealGesture:(UIPanGestureRecognizer *)recognizer

iOS - Show the animation/effect in runtime based on the guesture

When we perform a gesture(pan, rotate, swipe...etc), usually we navigate page, scrolling, etc. The back end recognize the gestures, that's all. What I am searching is more on UI. How can I make the screen to provide visual feedback of the gesture I have just performed?
In other words, when user's finger is on the screen, example when
Swiping - one line displays on the screen, tab - one dot displays on the screen, rotate - two curve of lines display on the screen
Let me know if my question is not cleared enough.
This question is quite a big ask. There are lots of different elements to it.
Firstly you'll need to detect gestures: How to detect Swipe Gesture in iPhone SDK?
You can find some code here on recognizing simple gestures.
Once you can recognize gestures, you can change the UIImage contained in a UIImageView programmatically like this:
UIImage *myImage = [UIImage imageNamed:#"swipe_pic.png"];
[myImageView setImage:myImage];
You can read more about UIImageView here.
Hope this helps you.

Animate image like deleting Apps from iPad/iPhone

I have a ScrollView with several UIButtons (custom type). The UIButtons are shown as Images. I made it to subclass UIButton to shoot an event if the user taps on a button for a long time (approx. 3 seconds).
If a user tap's one of the subclassed UIButtons i thought about animating the selected UIButton the way the apps are animated if you want to delete them.
I have nearly no experiance with animations. Is there something somebody can point me to? All i've found was transitions, but thats not what i need.
(Ill rephrase) On SO, there are quite a few questions to answer this. One of then is this link How do you make images wobble like on the iPhone home screen?

Resources