Pressing a UITableViewCell when a cell is currently swiped open - ios

I am using MGSwipeTableCell in my app. When a cell is swiped open to reveal buttons if I tap on another cell it dismisses the swipe cell (hides the buttons again). I want the previously swiped cell to dismiss the buttons and then select the new cell in one tap instead of two (i.e. tap off and then tap new cell). Is there any way to to do this?

See the description below, I think this delegate function of MGSwipeTableCell might help you.
-(void) swipeTableCell:(MGSwipeTableCell*) cell didChangeSwipeState:(MGSwipeState) state gestureIsActive:(BOOL) gestureIsActive
{
/**
* Called when the user clicks a swipe button or when a expandable button is automatically triggered
* #return YES to autohide the current swipe buttons
**/
}

On MGSwipeTableCell version 1.5.4 or later
cell.touchOnDismissSwipe = YES;
It will dismiss the cell you did swiped and also select the cell you tap

Related

Calling endEditing on a UIView

I have a tableView with two UITextViews. The user can add as many cells as they want by tapping on a "+" button. The tableView starts out with one row (cell). Lets say the user adds some information to the two textViews and then taps the plus button and scrolls to get to it. I call this function to dismiss the keyboard when a user scrolls so it isn't in the way:
override func scrollViewDidScroll(scrollView: UIScrollView) {
self.view.endEditing(true)
}
Now, the keyboard disappears and the user goes to tap on the second row's text field. The tableView jumps up (I think to accommodate the keyboard), but the textField can't be edited (no cursor and keyboard doesn't appear). If I go back up to the first row (row 0), the keyboard appears and I can edit the textView. Why is this happening?
There is a property on scrollView subclasses (e.g TableViews)
tableView.keyboardDismissMode = .OnDrag
Once the user begins a descending drag it dismisses the keyboard
scrollViewDidScroll calls everytime the tableview moves, so when "The tableView jumps up (I think to accommodate the keyboard)" it also calls and close the keyboard. You should add there some confines or put endEditing code in the other place.

Select a cell by UIButton - CollectionViewCell - Swift

I'm using collectionView, and I customized the collectionViewCell in a separate class with type (collectionViewCell). I want to perform an animation when user clicks on a cell. So, I created a UIButton in collectionViewCell and I customized it to cover the whole cell.
button = UIButton(frame: self.frame)
button.addTarget(self, action: "scaleToSmall", forControlEvents: .TouchDown)
self.addSubview(button)
Right now, the animation works perfectly, but the issue is I lost the ability select the cell, and the function didSelectItemAtIndexPath does not call anymore
I found out how to get the indexPath of the cell that has clicked,
But how can I call didSelectItemAtIndexPath again and tell it this cell is selected in order to perform the next action (segue to another ViewController) ???
Thanks in advance!!
You said that you created a button that covers the whole cell, if I have that right. Because of that, didSelectRowAtIndexPath won't do anything because that button is covering the whole cell. Take the Twitter app, for example. You can tap on the cell to open the tweet or you can tap on the user's profile image to open their profile. In this case, it's like you have the profile picture button covering the whole cell. Maybe you can set the animation in didSelectRowAtIndexPath or make the button smaller.
Hope this helps!

UICollectionView didselect and double tap conflict

There are two actions I tried to do.
Single tap which is select the cell to push to a new view controller.
Double tap to animate the cell.
I registered a double tap gesture and set doubleTapGesture.delaysTouchesBegan to ture. The single tap action is just a segue from cell to another viewcontroller.
However, there is a 0.5s delay if user single tap the cell to move to another view. The problem is the system wait for double tap gesture. If I remove the delaysTouchesBegan, it only recognize the did select cell function.
How can I reduce the delay?
Please add this line
tapgesture.delaysTouchesBegan = YES;
Assume there is a view (V) with UICollectionView (CV) inside it. Add double tap gesture to the V with settings:
doubleTap.numberOfTapsRequired = 2
doubleTap.delaysTouchesBegan = true
doubleTap.cancelsTouchesInView = true
Implement the didSelect of the CV.
It would be work separately the didSelect and the double tap. However because of delaysTouchesBegan it would be the delay before didSelect would fire.

UIButton & UITextField will block UITableViewCell being swipe to delete

There are UIButton and UITextField in the UITableViewCell. The delete button will not come up when I swipe over UIButton or UITextField. I do search for the answers on SO and google, there is a similar questions Swipe left gestures over UITextField, but no correct answers.
I got this problem on iOS 8.
Edit
After setting self.tableView.panGestureRecognizer.delaysTouchesBegan = YES;, it works perfect for cell with UITextField. But when i drag start from the UIButton, the delete button shows and the UIButton fired, which I do not want the UIButton get fired.
I don't know how to prevent the UIButton from firing in the first place, but UITableViewCell has the property showingDeleteConfirmation that can be used to check whether the Delete button is being shown. What I do is check this in the UIButton action for TouchUpInside, like this
- (void)buttonPressed:(id)sender
{
if (!self.showingDeleteConfirmation) {
// Handle button press
}
}
(This example is from a UITableViewCell subclass, so it uses self to access the property.)
This, in addition to the
tableView.panGestureRecognizer.delaysTouchesBegan = YES;
that you already have, works to get the swipe properly recognized and the button action not performed.

Unslide Delete Button UiTableViewCell

In my app, you can slide to delete a row as done here. After sliding, an alert pops up confirming the deletion. If you cancel it, I'd like to slide the row over so that the delete button is no longer visible. Right now I'm doing the following, but there's got to be a better way that looks more fluid.
self.tableView.reloadRowsAtIndexPaths([indexPath], withRowAnimation:UITableViewRowAnimation.Right)
disable edit mode on the tableView
objC: self.tableView.editing = NO;
swift: self.tableView.editing = false

Resources