I am a new programmer to Objective-C.
I use a storyboard in my app. It contains UITableViewController.
When I click it is cell using segue go to next view controller. But I want to use -(void)onLongPress:(UILongPressGestureRecognizer*) pGesture and show another ViewController by using the same cell.
My TableView shows Companies. I want to show company details according to cell LongClick.
You need to create a UILongPressGestureRecognizer.
Then you need to attach it to the view that you wish to recognise the longPress.
When you attach it you define an action selector and a target. The action selector is a method that will be trigged in the target when the gesture is recognised.
Assuming you create the gesture recogniser in your tableViewController and that is also the target then it would look something like this
then you create an action method to intercept the taps
If you are creating your table with dynamic cells, your longPGR creation should take place when you create the cell.
If you have static cells, you can make IBOutlet @properties connected to the cells concerned, and use that property in your longPGR creation.
To show the other viewController, it is not necessary to use a segue. You can push the new viewController onto the NavigationController’s stack in the longPress method:
That has the same effect as using a segue.