3

I'm building an exercise app. I have an array of exercises in my TableViewController, with each cell displaying a different exercise. The cells segue to a UIViewController. Within the UIViewController I would now like a user to be able to skip to the next exercise without having to go back to the TableViewController.

How can I refresh my ViewController containing the new data of the next exercise? (Similar to the reloadData method when constructing tables?)

I'm getting the next exercise in the array, but my page isn't refreshing. My code:

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()
}

Thanks!

1 Answer 1

0

You can use our codes and easily can do pagination. We already answered your question.

Example for load more indexs;

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

Thanks

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.