我想使用uitableviewrowaction来显示popoverview,用户可以在其中选择颜色。当我选择导航项作为发件人时,弹出窗口很有用。一旦我将发送者更改为tableViewCell,背景就会变暗,但是popover不会显示。这是我的代码
从导航项
提供的popover
uitableviewrowaction
override func tableView(tableView: UITableView, editActionsForRowAtIndexPath
indexPath: NSIndexPath) -> [AnyObject]?
{
var colorRowAction = UITableViewRowAction(style: UITableViewRowActionStyle.Normal, title: "Color", handler:
{ (action:UITableViewRowAction!, path: NSIndexPath!) -> Void in
self.performSegueWithIdentifier("popoverSegue", sender:self.mainTableViewOutlet.cellForRowAtIndexPath(path))
})
return [colorRowAction, deleteRowAction]
}
准备segue
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?)
{
if segue.identifier == "popoverSegue" {
colorPopover = segue.destinationViewController as SBColorPopover
colorPopover.modalPresentationStyle =
UIModalPresentationStyle.Popover
colorPopover.popoverPresentationController!.delegate = self
colorPopover.delegate = self
}
答案 0 :(得分:0)
解决方案:
因为我以编程方式调用performSegue,所以我必须定义popoverViewController的sourceRect:
colorPopover = segue.destinationViewController as SBColorPopover
colorPopover.modalPresentationStyle =
UIModalPresentationStyle.Popover
colorPopover.popoverPresentationController!.delegate = self
//define sourceRect
colorPopover.popoverPresentationController?.sourceRect =
sender!.frame
colorPopover.delegate = self