我正在建立一个动态的动作列表。当按下一个动作时,我想跳到表格视图中的一个部分。为此,我想知道操作的选定索引并将其替换为代码部分:“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)