Philographer

no index path for table cell being reused

엄청 이상한 오류가 로그에 찍혀서 찾아보았다.

언제 오류가 발생하는가 테스트 해보니, cell을 update할때

헤더셀에서 func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView?

함수를 호출하면서 오류가 나는 것을 알아냈다. 구글링해 보니 메인스레드에서 동작하는

headercell을 그리고 하는 tableView메소드에서 어쩌구 저쩌구 하는데 해결책은 이렇다.

return HeaderCell을 반환하는게 아니라 view를 반환한다.

func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let headerCell = tableView.dequeueReusableCellWithIdentifier("LocationHeaderCell") as! LocationTableViewHeaderCell


var view = UIView(frame: headerCell.frame)
headerCell.autoresizingMask = [.FlexibleHeight, .FlexibleWidth]
view.addSubview(headerCell)

return view
}

'IOS > Layout' 카테고리의 다른 글

IOS, iPhone 사이즈  (0) 2016.06.30
Scrollview Autolayout Bug  (0) 2016.06.28
Custom Modal 만들기 (alpha tip)  (0) 2016.06.26
ScrollView Auto Layout  (0) 2016.06.26
Auto Resize UITextView in Cell  (0) 2016.04.21
댓글 로드 중…

트랙백을 확인할 수 있습니다

URL을 배껴둬서 트랙백을 보낼 수 있습니다