UIView Receive Touch And Slide Action - iphone

I am a newbee in iOS development; and i want to develop a simple application.
In my application there is a view that is a member of xib. I want to receive user's touch and slide actions on my view to run some sliding animations.
I found some codes about this animation but i couldn't find how can i receive sliding action in UIView.
At least, i wanna explain why i used view. This view will contains two or more labes. So i couldn't be sure to choose Rect Button or UIView.
I hope you can help me.

You need to look at Gesture Recognizers. There are tonnes of resources and examples online. For example, here's an example on how to use swipe (slide) gesture recognizers.

Related

SWRevealViewController Pan gesture is not working when the from view is scrolling enabled

I have a side menu which is impelemented by SWRevealViewController and my frontView has a collection view.
SWReveal works fine by tap on menu button, but the pen gesture is not working on collection view (which has a horizontal scrolling enabled).
can any one help me to force collection view to accept the pen gesture of the SWReveal?
SWRevealViewController's gesture controller and collection view are been clashing that's why the problem occurs. Other than that as per my view there is no practical way to identify what user wants to open by the gesture.
But Client needs a solution and the image shows it! keep user interaction ON of the view.
Let me know if you find anything else.
Best of luck.
Add below code in viewDidLoad
self.view.addGestureRecognizer(revealViewController().panGestureRecognizer())

How to implement create event feature like the one in iPhone/iPad calendar?

I will implement a calendar application for iPad and I want the user to be able to create an event with almost the same experience as the native calendar app. (I took the images from iPhone but it's almost the same in iPad).
I have 3 questions:
As seen in the picture, to create an event the user does a long press on the day view. When he does this, there pops the purple rectangle with handles on it. To implement this by myself, will I create a UIView and add this to my view controller's view as a subview, above the table view that scrolls the hours below?
To make this event's rectangle longer, the user drags it from its handles. To implement this, will I override touchesMoved, etc... methods of the UIView I created?
To move this event between the hours, the user drags the rectangle up and down. My question here is that, when the UIView is dragged to the topmost, how will I scroll the tableview of the hours, so that the user is able to drag the event further to the top?
If you have any other recommendations, I'll be glad to hear them. Thx

Alternative to UIScrollVIew

I have a quick question. I am trying to implement an application where the user can navigate between the screens via swipe gestures. So I am using gesture recognisers to push and pop views, the problem with that is that I don't want the transition animation to apply to the entire screen as there are certain similar components and it looks weird.
I considered using a scroll view, however I don't want to load all the controllers at the same time.
Any suggestions?
I'd suggest looking into UIGestureRecognizer and setting the UIScrollView property delaysContentTouches to NO to prevent the scroll view from consuming touch events before your gesture recognizer has the change to process the input, if you'd prefer that approach.
Don't forget that UIGestureRecognizer offers you quite a lot of information when the gesture fires.
I would suggest using a scroll view and load only the visible controller. You can then look for this delegate method, and load the other controller lazily
- (void)scrollViewDidScroll:(UIScrollView *)scrollView

iphone switch views by swiping fingers to left and right, similar as the stock app

I am interested in how the lower portion of the iphone stock app is implemented. The lower part of the app, where you can switch the views by swiping your finger to left/right and the "..." below the view to indicate which view the user is looking at.
It looks to me a tabview component. I am trying to look for the UI component as well as google it, but i have not yet find anything like it. Most of the examples I found are using scroll view. When you swipe the finger to left/right the scroll bar appears, and more importantly, there is no "..." under the view to indicate which view the user is looking at.
Could anybody point me to a similar example?
Thanks,
Thomas
It's a UIScrollView with pagingEnabled set to YES taking up most of the screen with a UIPageView underneath it. See Apple's PageControl sample code for details.
You can turn off showing the scroll indicators by setting the showsHorizontalScrollIndicator and showsVerticalScrollIndicator properties of the scroll view to NO.
It might also be worth checking out the PhotoScroller sample code for an in-depth example of how to do pagination using a UIScrollView. There's also a great video called "Designing Apps with Scroll Views" that walks you through paginating views using a UIScrollView in the WWDC 2010 videos. I highly recommend watching it and the other WWDC videos. You can get them by signing into the iOS developer center and scrolling to the bottom.
Also, like they tell you in the video, you don't need to use touch events or override touchesBegan:withEvent: or similar functions to make this happen. If you do it that way, you have to do lots of work to pass events that you don't care about through to the views you're showing and stuff like that. UIScrollView with pagingEnabled set to YES does all of the hard work for you.
If you don't want to use a scroll view for some reason, using a UIGestureRecognizer is the way to go. But really, just use a scroll view.
This is called touch events. more so Swipe touch on the iphone.
And here are two examples.
Heres a code snippet:
You first need to tell the application that touchesBegan.
You can find some details on the API for this. Then the delegate methods will be called automatically everytime a user touches the iphone screen.
- (void)touchesEnded:(NSSet*)touches withEvent:(UIEvent*)event {
UITouch *touch = [touches anyObject];
if (touch.info & UITouchSwipedRight) {
[self changeViewRight];
} else if (touch.info & UITouchSwipeLeft) {
[self changeViewLeft];
}
return;
}
check this example:
http://devblog.wm-innovations.com/tag/touchesbegan/
Its a really good example.
Hope this helps.
Let me know if it did a little. Thanks
PK
Take a look at following link, it might be nice approach to navigate through views on swipe.
Views Navigation Using Swipe Gesture

How do I add a touch event to a subview of UIView?

I'm trying to build by very first app so excuse my ignorance. I love the sample code that Apple put together here called ViewTransitions:
http://developer.apple.com/iphone/library/samplecode/ViewTransitions/Introduction/Intro.html
I want the transition to occur after a user taps the screen once instead of the button like the code does.
Thanks!
Change the inherited class of your xib to be UIControl.
Implement the touch events in your view.