我正在尝试在Swift 2中实现
如下所述,我认为在创建
为了以编程方式完成此操作,我的理解是需要在
在我的代码中,detailDisclosure chevron被绘制出来了,但我分配给它的目标动作方法没有被调用。
然后,我需要为按钮创建按下时的处理程序:
最后,
accessoryButtonTappedForRowWithIndexPath:
,并且使用UITableViewController
。如下所述,我认为在创建
disclosureIndicator
时缺少了某些内容,但我不知道是什么。它从代码中绘制出来,但我的目标操作没有被调用。 呜呜!为了以编程方式完成此操作,我的理解是需要在
cellForRowAtIndexPath
中添加detailDisclosure指示器,然后才返回cell
。 我正在按以下方式执行:// Create disclosure indicator button in the cell
let disclosureIndicatorButton = UIButton(type: UIButtonType.DetailDisclosure)
disclosureIndicatorButton.addTarget(self, action: "disclosureIndicatorPressed:event:", forControlEvents: UIControlEvents.TouchUpInside)
customCell.accessoryType = .DisclosureIndicator
在我的代码中,detailDisclosure chevron被绘制出来了,但我分配给它的目标动作方法没有被调用。
然后,我需要为按钮创建按下时的处理程序:
func disclosureIndicatorPressed(sender: UIButton, event: UIControlEvents) {
print("disclosure button pressed")
// convert touches to CGPoint, then determine indexPath
// if indexPath != nil, then call accessoryButtonTappedForRowWithIndexPath
}
最后,
accessoryButtonTappedForRowWithIndexPath
包含执行segue的代码,这部分我已经完成。我还缺少什么?
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITableViewDelegate_Protocol/#//apple_ref/occ/intfm/UITableViewDelegate/tableView:accessoryButtonTappedForRowWithIndexPath:
DisclosureIndicator
只是装饰性的,除了被绘制出来之外没有任何作用。DetailDisclosureButton
实际上可以与操作相关联。感谢您帮我解决了这个问题。 - Adrian