I'm creating a UiTableView with 2 different cell nibs. it is working perfectly fine expect 1 specific scenario.
ISSUE: On cell selection, i perform some action in didSelectRowAtIndexPath. After didSelectRowAtIndexPath execution, iOS invokes cellForRowAtIndexPath method and recreates that clicked cell.
What is the affects of recreation: My cells heights are dynamic. When UiTableView recreates any cell from middle, it causes unnatural jerks on scrolling back/up.
Below is the code snippet of my methods. Any help would be appriciated :)
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
var post = self.posts[indexPath.row]
if(post.valueForKey(MEDIA) != nil) {
var cell:PostImageTableViewCell = self.tableView.dequeueReusableCellWithIdentifier("PicCell") as PostImageTableViewCell
cell.loadPostData(post)
return cell
} else {
var cell:PostTableViewCell = self.tableView.dequeueReusableCellWithIdentifier("Cell") as PostTableViewCell
cell.loadPostData(post)
return cell
}
}
Selection method:
func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
self.selectedRow = indexPath.row
self.performSegueWithIdentifier("detailSegue", sender: nil);
self.tableView.deselectRowAtIndexPath(indexPath, animated: true)
}
Call Stack: