0
저는 UITableView가 있고 스크롤하는 동안 저크를 생성하는 tableView의 "CellForRowAt"대리자 기능에 내 사용자 지정 UIView의 nib 파일을 포함합니다. 예 :스크롤하는 동안 저크를 생성하는 CellForRowAt에 사용자 지정 UIView 용 nib 파일 포함
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier:
"cell", for: indexPath) as! CustomCell
let customView: CustomView = Bundle.main.loadNibNamed("CustomView", owner:
self, options: nil)![0] as! customView
cell.customViewPlacement.addSubview(customView)
return cell
}
어떻게하면 코드를 수정할 수 있습니까? 이것은 회원님이 셀을 만들고 기본적으로 새로운 뷰를 생성하는, 당신의 cellForRow
에서 재사용 (중복 만들고 유지)마다 휴대 스크롤을 추가, 따라서 그것은 경련을 어떻게 감사
아니요, 잘못되었습니다. tableViewCell의 펜촉을 만들지는 않습니다. customView는 셀에 배치 한 뷰입니다. let customView : CustomView = Bundle.main.loadNibNamed ("CustomView", 소유자 : 자기, 옵션 : 없음)! [0] as! customView // this is my customView ............ cell.customViewPlacement.addSubview (customView) // 여기 내 customView를 배치합니다. –
그게 틀린 부분이라면, 당신이 말하는 뷰가있는 셀을 포함하는 펜촉을 만들고, 그것을 분리하지 말고, 어떤 이유로 든 할 수 없다면, 뷰를 'CustomCell' 클래스의' 'cellForRow'가 아니라'awakeFromNib' – Tj3n