How to access the UITableViewRowAction iOS 8 view

I performed some editing actions for table view rows using UITableViewRowAction . One of them is the delete action, and I want to introduce a popover containing an action sheet to confirm the delete action. So I need a link to the presentation of the delete button to pass it to the UIPopoverPresentationController .

Is there a way to access the representation of a UITableViewRowAction object?

To clarify a bit, a view trying to access is a red delete button, marked in green:

enter image description here

+6
source share
2 answers

Sorry, I do not know the Objective-C version of this, but I am using this in my project right now in Swift, and it should work. This is iOS 8, although I'm not sure there is a way to do this before this.

 func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [AnyObject]? { var deleteButton: UITableViewRowAction = UITableViewRowAction(style: .Default, title: " ", handler: { (action, indexPath) in // put whatever you need to call here. below is the default code, which will delete the cell as usual. self.tableView.dataSource?.tableView?( self.tableView, commitEditingStyle: .Delete, forRowAtIndexPath: indexPath ) return }) } return [deleteButton] } 

Another option is to use the tableview function:

 func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) 

Here you can create a popup and confirm it. This will probably work better, I believe that is exactly the kind of thing for this feature.

Edit: forgot return [deleteButton] in this first bit of code.

+1
source

UIView * view = sender.superview; // Cell contentView

 CustomCell *cell; // (you can custom tableviewcell name if created) if(SYSTEM_VERSION_GREATER_THAN(@"8.0")) { cell = (CustomCell *)view.superview; } else{ cell = (CustomCell *)[[[sender superview] superview]superview]; } And Access it by :- cell.view 
-1
source

Source: https://habr.com/ru/post/976144/


All Articles