didSelectRowAtIndexPath doesn't work on xCode 9 - ios

So I have to work on this really big project, it's still on objective C.
I was just ask to make a really small change (hide a button) so I did that and it's building fine and everything looks normal but then all of the tableView in the project won't react as in didSelectRowAtIndexPath is never called (scrolling work and the data are correctly displayed)
The only thing that changed compared to before is that I used xCode 9.
Now when I build it using xCode 8 it's working again so at least we can go ahead but I still am wondering what is happening.
I made a smaller project using exactly the same logic as the main project (the cell are custom, you can swipe etc)
and when I did it from scratch, it's working fine.
So I fell like it's more of an xCode bug/error than one with the code.
would someone have any idea ?

Have you used tap anywhere on that UI??
because when tap: UITapGestureRecognizer is there in UI didselect work after only at longpress of cell
or you can just set in your viewdidload function
UITapGestureRecognizer *gestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:#selector(hideKeyboard)];
[self.tableView addGestureRecognizer:gestureRecognizer];
gestureRecognizer.cancelsTouchesInView = NO;

Please check the following
It should be single selection
It should be interaction enabled
And check you have created any button on top of all layers which is targeting some other action.
Check it and reply.

Related

My uitableview cells using in anywhere in application are only selectable on long press ios 9.2, I am not using any gestures

I am using custom xib cells in my application but I am facing a problem regarding all tableviews, UITableViewCell is not getting selected on single tap, I have to long press the cell for selecting it. I am using a custom xib cell and I have not used any gesture recognizer in my classes. I am facing this problem in every table view even in NIDropdownList’s Tableview Which is an open source library I have previously used many time..
I was using CDSideMenu and TSMessage library which contains UIGestureRecognizers in it.
UISwipeGestureRecognizer *gestureRec = [[UISwipeGestureRecognizer alloc] initWithTarget:self
action:#selector(fadeMeOut)];
[gestureRec setDirection:(self.messagePosition ==TSMessageNotificationPositionTop ? UISwipeGestureRecognizerDirectionUp :
UISwipeGestureRecognizerDirectionDown)];
[self addGestureRecognizer:gestureRec];
[gestureRec setCancelsTouchesInView:NO];
I have set All the gestures to not cancel other touches in view and its solved the problem [gestureRec setCancelsTouchesInView:NO] :)

UITapGestureRecognizer makes certain fields unclickable

I'm using a UITapGestureRecognizer on the lowest down view (self.view) to hide my keyboard.
UITapGestureRecognizer *tapHandler = [[UITapGestureRecognizer alloc] initWithTarget:self action:#selector(handleBackgroundTap:)];
[self.view addGestureRecognizer:tapHandler];
And the handleBackGroundTap method simply does
[self.view endEditing:YES];
And this code works fine on most of my views except for a couple
a view where i'm using a tableview populated with clickable items (it's a list of checkboxes really)
a view that uses a datepicker (the datepicker should open when you click the textfield)
On those two views said items become unresponsive: the checkboxes are unclickable (they don't mark or unmark when tapped) and the datepicker refuses to show.
My question is: why? And: are there any workarounds?
Note: if I don't add the gesture recognizer the fields work fine but not being able to dismiss the keyboard is rather annoying.
so as I was looking around i happened to stumble across a solution (which is typical... Have been searching for days and the moment I post a question I find the solution)
In any case adding
[tapHandler setCancelsTouchesInView:NO];
solved the issue
edit: I have to wait 2 days to accept this as the answer...

UITapGestureRecognizer issue in iOS 9

I guys,
today I've updated my iPhone to iOS 9 and now have problems with a gesture recognizer.
This is the error:
WARNING: A Gesture recognizer (; target=
<(action=onVideoTap:, target=)>>)
was setup in a storyboard/xib to be added to more than one view
(->; layer = >) at a time, this was never allowed, and is now enforced.
Beginning with iOS 9.0 it will be put in the first view it is loaded
into.
I didn't have this problem with iOS8.
The view contains a UIImageView and a TextView. The recognizer was dropped into the ImageView and has only referncing outlets to this view.
I don't really understand this issue.
Can somebody help me? Thank you :)
This was happening with me because I wanted to use a Tap Gesture Recognize with an image in a TableViewCell contained in a TableView.
The problem is that:
I add one Tap Gesture Recognizer but I have more than one TableViewCell (more than one image) in my table.
iOS will assign the UITapGestureRecognizer to the first image in the first cell, and other cells will be without gestures (the gesture already set to the first image only).
To Solve this problem follow this:
Make sure you checked User Interaction Enabled for the UIView you want to assign with a TapRecognizerGesture.
in the sub-view TableViewCell in my case add a new UITapGestureRecognizer. The code:
internal let tapRecognizer1: UITapGestureRecognizer = UITapGestureRecognizer()`
In your main view TableView in my case and for every cell assign the UITapGestureRecognizer you made with each cell to a main function in the main view:
cell.tapRecognizer1.addTarget(self, action: "img_Click:")
cell.img.gestureRecognizers = []
cell.img.gestureRecognizers!.append(cell.tapRecognizer1)
Add the function you want UITapGestureRecognizer to fire when clicked:
func img_Click(sender: UITapGestureRecognizer) {
print("ok")
}
Notes:
You can use simple way if you do not want the UITapGestureRecognizer action in the main view by assigning it in its sub-view directly.
in step 4 function name must be the same as in addTarget line.
I think that this problem happen when you use storyboard added a Tap Gesture Recognizer. Because some reasons you added more than one views.(see the picture).
So, delete other wrong views,leave the right one view.
Already fixed it.
The storyboard is localized and in one language I assigned the the recognizer twice to the picture view.
Somehow this seemed to cause troubles on the other storyboards too.

Unable to override swipe to delete cell functionality for iOS v > 6.1

We are developing an iPad application where entire UI is created using Storyboard file.
In one of the view controller scene, there is a UITableView which contains a custom cell.
When I swipe to the table cell, a delete button appears for that.
How to disable this swipe to delete functionality. We have our own Edit button on top navigation bar, which sets UITableView's editingMode. We require to disable swipe to delete funcitonality.
Here is what we have already tried:
1. Overriden swipe gesture method:
UISwipeGestureRecognizer *gestureR = [[UISwipeGestureRecognizer alloc]
initWithTarget:self action:#selector(handleSwipeFrom:)];
[gestureR setDirection:UISwipeGestureRecognizerDirectionRight];//|UISwipeGestureRecognizerDirectionRight)];
[myTableView addGestureRecognizer:gestureR];
We have tried this gesture with both, myTableView as well in CustomCell file.
2. Remove swipe gesture method:
UIGestureRecognizer* swipe = [[self.tableView gestureRecognizers] objectAtIndex:2];
[myTableView removeGestureRecognizer:swipe];
Both of those code blocks are not working for us.
This issue is there only for the iOS 7 only, as there is default swipe to delete given for UITableView.
Please suggest a solution for this.
(1.) is not really an override. It seems adding multiple recognisers could have undefined results.
(2.) looks like a private API hack, so also not advisable.
Instead, the editing behaviour of a table view is controlled by overriding these methods:
- tableView:willBeginEditingRowAtIndexPath:
– tableView:editingStyleForRowAtIndexPath:
See the documentation for details.

UITableView - move cell - How to enter dragging mode without long press?

I am using the standard UITableView editingMode to move Cells via Drag & Drop. Works like a charm, perfectly integrated to my Core Data Model and everything.
However, usability-wise I dislike that the user has to long-press the Editing Accessory (|||). I would like to change the minimum duration of the UILongPressGestureRecognizer to something like 0.1f.
The trouble: I cant seem to access the right Gesture Recognizer. UITableViewCell's gestureRecognizers-array is empty, the UITableView's gestureRecognizers array contains only private recognizers:
UIScrollViewDelayedTouchesBeganGestureRecognizer
UIScrollViewPanGestureRecognizer
UISwipeGestureRecognizer
UIGobblerGestureRecognizer
I looked at several github-Projects:
https://github.com/bvogelzang/BVReorderTableView
https://github.com/FlorianMielke/FMMoveTableView https://github.com/mystcolor/JTGestureBasedTableViewDemo https://github.com/shusta/ReorderingTableViewController
They all focus on re-engineering UITableView so you dont have to access the built in editing mode - and instead can long press any UITableViewCell anywhere WITHOUT entering editing mode.
As I simply want to change the minimumPressDuration of the built in editing mode (and am actually fine with restricting the "access point" for the drag gesture to the Accessory View) I am reluctant to use these custom implementations potentially prone to errors and trouble.
Looking forward to your help! Thank you!!
Cheers,
Chris
You may want to access the UITableViewReorderControl, as discussed in this article, and then look for any attached gesture recognizers. If you find any, you should then be able to change the minimumPressDuration property.
Swift 5
You can change the minimumPressDuration to 0. So that you can enter drag and drop mode without a long press.
let gesture = UILongPressGestureRecognizer(target: self, action: #selector(handleLongPress))
gesture.minimumPressDuration = 0

Resources