アクションの動的リストを作成しています。アクションを押すと、テーブル ビューのセクションにジャンプしたいと思います。このために、アクションの選択されたインデックスを知り、それをコードセクション「inSection: 0」に置き換えたいと思います。それを行う方法はありますか?
これが私のコードです:
let optionMenu = UIAlertController(title: nil, message: "Jump to", preferredStyle: .ActionSheet)
for item in items {
let action = UIAlertAction(title: item, style: .Default, handler: { (alert: UIAlertAction!) -> Void in
let indexPath = NSIndexPath(forRow: 0, inSection: 0)
self.tableView.scrollToRowAtIndexPath(indexPath, atScrollPosition: UITableViewScrollPosition.Bottom, animated: true)
})
optionMenu.addAction(action)
}
self.presentViewController(optionMenu, animated: true, completion: nil)