3
我正在构建一个练习应用程序。我在TableViewController中有一系列练习,每个单元显示不同的练习。单元格延伸到UIViewController。在UIViewController中,我现在希望用户能够跳到下一个练习,而不必返回到TableViewController。用Swift中的新数据刷新UIViewController
如何刷新包含下一个练习的新数据的ViewController? (类似于构建表时的reloadData方法?)
我正在下一个练习中,但是我的页面不刷新。 我的代码:
var exercise: Exercise?
var exerciseList: [Exercise]!
// toolbar item button pressed:
@IBAction func nextExercise(sender: UIBarButtonItem) {
if let currentIndex = exerciseSet.indexOf(exercise!) {
let nextIndex = currentIndex + 1
let nextExercise = exerciseList[nextIndex]
reloadData(nextExercise)
}
}
private func reloadData(displayedExercise: Exercise){
exercise = displayedExercise
self.view.setNeedsDisplay()
}
谢谢!