2016-08-19 3 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

감사

관련 문제