0
새 셀을 추가하려고합니다. 내가 어떻게 할 수 있니? 도와주세요! 내가신속한 새로운 정적 셀 테이블 뷰 삽입
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
if section == 1 {
return 3 + eventDates.count
} else {
return super.tableView(tableView, numberOfRowsInSection: section)
}
}
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
if (indexPath.section == 0 && indexPath.row == 1) {
eventDaysVisible = !eventDaysVisible
tableView.reloadData()
tableView.insertRowsAtIndexPaths([NSIndexPath(forRow: eventDates.count + 3, inSection: 0)], withRowAnimation: .Automatic)
tableView.reloadData()
}
for day in eventDates {
print("OBJ: \(day)")
}
tableView.deselectRowAtIndexPath(indexPath, animated: true)
}
나는 3 개 정적 세포와 새로운 세포를 가지고 내가 버튼을 전환하는 경우 최초의 후 삽입 할 필요가보십시오.
var eventdates = Friday, Saturday, Sunday
당신이 저를 도울 수 있기를 바랍니다.
탭 leView.insertRowsAtIndexPaths는 추가 할 indexPath 배열을 사용합니다. 이 예제에서는 3 개의 개별 indexPath를 전달하고자합니다. – JohnMorrison
위의 내 응답을 업데이트하여 indexPaths가 전달 된 경우 배열을 만드는 방법을 보여 주었지만 레이아웃에서 예상하는 내용이 확실치 않아서 정렬 할 때까지 작동하지 않을 수 있습니다 (두 섹션, 1 행 섹션/행 선택은 행 삽입을 처리해야합니까? code numberOfRowsInSection은 섹션 수에 행 수를 추가하지만 섹션 0에 새 행을 추가합니다.) – JohnMorrison
ok - Ive가 기본 응답을 다시 표시하도록 수정되었습니다. 작업 예제. 동일한 접근 방식을 사용할 수 있습니다. – JohnMorrison