Tweetie 2/Facebook-like swipe gesture in UITableview? - iphone

Hey everyone, I was just wondering if anyone knows how to create a UITableviewCell swipe effect akin to the one in the Tweetie 2.0 app (see video: Tweetie 2.0) or in the Facebook 3.0 app (when pressing the blue "+" next to a status).
What I need to do is to have the cell slide away in response to you swiping it and reveal a background view.
Any help would be appreciated!

Both Tweetie and Facebook implement their own 'custom' swipe detection. What I mean is that instead of using the standard UITableView hooks for swipes, you override touchesBegan:withEvent:, touchesMoved:withEvent:, et.c in your own subclass of UITableView. You can then start detecting swipes yourself and call whatever methods you want on your UITableViewCell's. (Hint: to get the cell given an UITouch, use the UITableView method indexPathForRowAtPoint:)
There's also a another plus to managing your own swipes: you get a lot more control over how accurate each swipe needs to be.

Related

Two finger swipe on a UITableView

I am using a UITableView in my application to show a set of images under each section in a UITableView.I have a requirement which makes the UITableView to scroll to next section if the swipe is done with two fingers.
Can some one help me in making the UITableView respond to two finger swipe.I tried by assigning a swipe gesture with number of touches assigned to two but the table responds to normal traditional scroll.
Can someone suggest a way to implement this.If possible with pieces of code which is well appreciated.
TNQ
[swipeGesture setCancelsTouchesInView:TRUE];
This will make the gesture recognizer swallow the touches.
Hope this helps.
Cheers!

backgroundView for a UITableViewCell that is being reordered?

I'm trying to change the background view for cells that the user starts to drag with the handle out on the right hand side.
Apparently the selectedBackground view is not used in this state, is there any other solution?
This seems to be a tough one. It doesn't seem as if Apple has provided a way to notify the developer that the user has started reordering a table view cell. So I think this is what you'd have to do:
Subclass UITableViewCell.
Override the touchesBegan et al methods (this might get you started: http://devblog.wm-innovations.com/2010/03/30/custom-swipe-uitableviewcell/)
If you detect a "drag" touch event and the cell's showsReorderControl property (see http://developer.apple.com/library/ios/#documentation/uikit/reference/UITableViewCell_Class/Reference/Reference.html) returns YES, swap out the backgroundView, remembering the previous one.
When the touch event ends, restore the old view.
Realize that it's not as easy as above 4 steps.
Custom touch handling inside a tableview is possible but hard. You might have to temporarily disable touch events in the UITableView (climbing up the responder chain) to make this work.
I hope these pointers get you moving in the right direction, though.

UIView Receive Touch And Slide Action

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.

UITableViewCell Swipe for Drawer

This is really more of a curiosity than a hard coding question.
Both Facebook and Twitter both have a feature where swiping a UITableViewCell animates the cell off the side to reveal a drawer with more controls underneath. How is something like that accomplished?
Here is a great open-source method for doing exactly this, based on the behavior of the Twitter app:
https://github.com/thermogl/TISwipeableTableView
This is a problem I have tried a couple of different solutions to. I really liked the behavior of Mailbox (mailboxapp.com). So I set out to achieve this. In the end I ended up with what I believe is a very simple solution: use a UIScrollView inside your cell. I have blog post that discusses and a sample app that demonstrates this behavior.
2 ways to detect swipt action
look at the willTransitionToState: method of UITableViewCell.
this method will be invoked when you swipe at the cell.
Custom swipe detection in a TableViewCell
and then you can change your cell view easily.
You could just implement -tableView:willBeginEditingRowAtIndexPath: in your table view delegate.
From the doc,
This method is called when the user swipes horizontally across a row; ... This method gives the delegate an opportunity to adjust the application's user interface to editing mode.
As a UITableViewCell is just a UIView, you can use this fact to basically do anything you like with it.
To solve your problem, I'd attach a UISwipeGestureRecognizer to detect the swipe and then animate the view to a different state.
For example, you could create a custom cell that has it's content view laying above the "actions view". Whenever there is a swipe, you use a UIView animation to move the content view aside and show the action view with a couple of buttons instead. In a custom UITableViewCell you could add a delegate protocol to have the pressed action and the cell being sent to the delegate, i.e. your controller. There you'd trigger what ever there is to trigger and then transition the cell out of the state.

Handling UITableCell move left (or move right) event?

I want to creat an UITableView which each cell (UITableCell) in this table can be moved left or moved right (System will be notified when user touchs down the cell and moves finger to left or right). Anybody can tell me how can i do it :) Thanks :)
I want to build a Table which each TableCell in it become a menu likes image bellow when user touch up TableCell and move finger to left or right!
I would guess this is done by watching for the touch events, being the first responder and monitor all touch events before you send them further to the UITableView under.
I think there is a source code from Apple that shows this.. think it's called Gestures or TableView Gestures... do a search on the Apple site.
Also, do read on the UIGestureRecognizer docs from the SDK. These can be attached to a certain view, I read.
Good luck, let us know if you're successful.