0
我有表格视图有一个“添加”按钮,你点击添加按钮和一个新的视图控制器模态地打开,你输入文本字段(名称,位置,评级,等等......),当你点击保存它会带你进入包含你在“添加视图控制器”中输入的所有信息的玩家个人资料页面。我还在玩家个人资料页面上有一个Unwind Segue让你回到这个表格视图列出了你添加的所有球员,我的问题是当我点击松开回表格视图的按钮时,它不会添加新的球员IE如果我的表格视图中有3名球员开始,我点击add添加第四个,输入信息并点击保存,然后进入播放器配置文件页面,当我点击展开按钮时,表格视图仍列出3,而不是4.下面是我的Unwind代码...展开塞恩重新加载更新的表格视图单元格
@IBAction func unwindToRecipeList(segue: UIStoryboardSegue) {
if let sourceViewController = segue.sourceViewController as? RecipeDetailViewController, recipe = sourceViewController.recipe {
if let selectedIndexPath = tableView.indexPathForSelectedRow {
recipes[selectedIndexPath.row] = recipe
tableView.reloadRowsAtIndexPaths([selectedIndexPath], withRowAnimation: .None)
} else {
let newIndexPath = NSIndexPath(forRow: recipes.count, inSection: 0)
recipes.append(recipe)
tableView.insertRowsAtIndexPaths([newIndexPath], withRowAnimation: .Bottom)
}
还不行。我是否必须以不同的方式将数据传回我的表格视图? –
你是否正确地从你的sourceviewcontroller获得配方?,你可以在你的else语句中打印吗?,然后在追加配方后打印配方。 – valencieu