呼び出されたからがUITableViewController取り込まれました。NSManagedObjectsNSFetchRequestviewDidLoad
0を返す をmyTableViewController除いて、すべてが希望どおりに機能します。accessoryButtonTappedForRowWithIndexPathindexPath
これが私が実装している方法ですaccessoryButtonTappedForRowWithIndexPath:
override func tableView(tableView: UITableView, accessoryButtonTappedForRowWithIndexPath indexPath: NSIndexPath) {
performSegueWithIdentifier("reorderSequences", sender: UIButton())
}
これが私のものperformSegueWithIdentifierです:
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "reorderSequences" {
// Get a hold of the item to send to the destinationVC
let button = sender as! UIButton
let hitPoint = button.convertPoint(CGPointZero, fromCoordinateSpace: self.tableView)
if let indexPath: NSIndexPath = self.tableView.indexPathForRowAtPoint(hitPoint) {
// ** Regardless of which accessoryButton I press, the indexPath
// for index 0 is always the value **
print("\nhitPoint's x: \(hitPoint.x)\n hitPoint's y: \(hitPoint.y)")
let selectedThingSequence = self.thingSequences[indexPath.row]
print("prepareForSegue's indexPath is \(indexPath)")
// set up the segue
let destinationVC = segue.destinationViewController as! ReorderTableViewController
destinationVC.thingSequenceToReorder = selectedThingSequence
print(controller.description)
}
}
}
私の理解では、送信者として を使用して、送信者が住んでいる場所UIButtonを把握できます。明らかに、そうではありません。私は何が欠けていますか?indexPathperformSegueWithIdentifier
アップデート
簡単な質問には、簡単な答えがあります。
で、次のようprepareForSegueに作成indexPathしました。sender
override func tableView(tableView: UITableView, accessoryButtonTappedForRowWithIndexPath indexPath: NSIndexPath) {
performSegueWithIdentifier("reorderThings", sender: indexPath)
}
ではprepareForSegue、次のように渡された indexPath を取得しました。
let indexPath = sender as! NSIndexPath
一連のセグエを実行している場合は、注意が必要です。私の目的では、それは機能します。正しい方向に向けてくれた Tom Harrington に感謝します。