2016-08-19 9 views
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() 
} 

ありがとう!

答えて

0

私たちのコードを使用すると、ページネーションを簡単に行うことができます。私たちはすでにあなたの質問に答えました。

さらにインデックスをロードする例。

if indexPath.row == privateList.count - 1 { // last cell 
    if totalItems > privateList.count { // more items to fetch 
     loadItem() // increment `fromIndex` by 20 before server call 
    } 
} 

Swift tableView Pagination

おかげ

関連する問題