您是否有任何方式打开一个UIPresentationController,当向左滑动触发并点击编辑?
func tableView(tableView: UITableView,editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? { let delete = .... let edit = UITableViewRowAction(style: .Normal,title: "Edit") { action,index in //OPEN UIPresentationController HERE } return [delete,edit] }
解决方法
和@patchdiaz一样,我不是100%肯定你想做什么.但是,这个代码块可能足以实现您的目标:
override func tableView(tableView: UITableView,editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [AnyObject]? { let edit = UITableViewRowAction(style: .Normal,index in // OPEN UIPresentationController HERE let vc = UIViewController(nibName: nil,bundle: nil) vc.view.frame = CGRect(x: 0,y: 0,width: 100,height: 200) vc.view.backgroundColor = UIColor.orangeColor() vc.modalPresentationStyle = .Popover let popover = vc.popoverPresentationController! let cell = tableView.cellForRowAtIndexPath(indexPath)! var cellAbsolutePosition = cell.superview!.convertPoint(cell.frame.origin,toView: nil) cellAbsolutePosition.x = cell.frame.width - 60 popover.sourceRect = CGRect(origin: cellAbsolutePosition,size: cell.frame.size) popover.sourceView = tableView self.presentViewController(vc,animated: true,completion: nil) } return [edit] }
它会在“编辑”按钮位置显示一个popover权限,如下所示:
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。