를 업데이트 할 때있는 UITableViewCell 점프 ... 구조체 배열에서 아래로 스크롤 할 때, 정상까지 스크롤하지 않을 때는 가끔 이동합니다 jQuery과 원인,하지만 난 상단을 향해 스크롤 할 때스위프트 나는이처럼 내있는 UITableViewCell 내 UILabel의 텍스트를 업데이트 할 때 UILabel의 텍스트
이런 일이 발생하는 이유 .... 이해할 수없는
구조체는 데이터 내가 서버에서 얻는 결과에서 추가되는
struct ContentStruct {
var textLink : String? = ""
var title : String? = ""
var text : String? = ""
}
CellForRow
let postData = cellContentArray[(indexPath as NSIndexPath).section]
cell.binData(content: postData)
TableViewCell
func binData(content: ContentStruct) {
self.titleLabel.text = content.title
self.text.text = "yytytytyt"//text
self.uuidLabel.text = "yhhyhyhyyh"
}
나는 크기를 조절하고 세포의과 같이 :의 viewDidLoad에서 : 다음
tableView.rowHeight = UITableViewAutomaticDimension
그리고이 :
func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
let height = self.heightAtIndexPath.object(forKey: indexPath)
if ((height) != nil) {
return CGFloat(height as! CGFloat)
} else {
return UITableViewAutomaticDimension
}
}
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
let height = cell.frame.size.height
self.heightAtIndexPath.setObject(height, forKey: indexPath as NSCopying)
}
어떤 아이디어가?
미리 감사드립니다.
데이터 소스 코드 추가 –
@WetSweater 그 의미가 확실하지 않은가요? tableView 코드? 또는 구조체 코드? 이전에 내 서버에서 다운로드 한 결과에서 구조체에 데이터를 추가하고 있습니다 ... 그리고 나서 tableViewCell을 정상적으로 업데이트하고 있습니다 ... 다른 곳에서는 보이지 않는 세 번째/네 번째 셀에서만 발생하기 때문에 이상합니다. 그것은 내가 아주 anoying 찾을 작은 플래시이야 –
cellForRow 메서드의 전체 내용은 제안을 제공하는 데 도움이 될 것입니다. 당신은 어딘가에 tableView를 다시로드하고 있습니까? – Stephen