iOS 8: UITableViewCell detail text not correctly updating

萝らか妹 提交于 2019-11-30 06:38:23

Having the same problem. My solution was to call [cell layoutSubviews] before returning the cell at the end of -tableView:cellFForRowAtIndexPath. This works for me, and I didn't find it necessary to override layoutSubviews in the cell subclass.

I have same problem with cell not updating correctly when using segue in storyboard. Tried

[setNeedsLayout] and [layoutIfNeeded]

on the view and the tableview and it is NOT working.

[self.tableView reloadData] is in viewDidAppear, as it should.

Then I tried the advice from pixbug, and it worked. But one should NOT use [layoutSubviews] directly. So I tried the ones that is adviced by the documents on the cell instead of tableView or the view.

Tried

[cell setNeedsLayout] 

but this did NOT work.

Tried

[cell layoutIfNeeded] 

this WORKED for me.

I put this before returning the cell.

I had the same problem in an iOS 8 storyboard (without Auto Layout enabled).

I had a Table View with a static Table View Cell at the bottom of it. In IB, I added some spaces into that table cell's content area (Style: "Right Detail"). Then in code (ViewDidLoad), I updated that cell's content with...

self.copyrightsCell.detailTextLabel.text = @"<a string>";

WITHOUT the IB spaces, the cell was INVISIBLE in portrait mode.

But WITH the initial spaces, the cell's content later appears correctly.

Hope this helps someone.

I have the same issue. I have am certain that the data is available and being assigned to the cell.detailTextLabel.text I have noticed that once a value has been assigned then there is no flicker if the value is changed on the return to the tableView. So it appears to me that there is only an issue on the first assignment of a value to the detailTextLabel.

So, I followed this tread and many others. This one lead me to what seems to be the correct answer. I hope this helps others, since this has driven me crazy since iOS 7 / 8 made some sort of changes.

My answer was to put the normal processing code in viewWillAppear and add this [self.tableview layoutSubviews] instead of [self.tableView reload data]. I think this has to do with Apple making things much more controllable in iOS 7 / 8. I struck upon that idea when reviewing some info on how cells were working.

Again, I hope this helps others resolve this annoying problem.

I think that if you need to reloadData, that means that the table data isn't loaded when its created.

You'd just need to load your data in the viewdidload (or somewhere else BEFORE the table view gets its data ) where your tableview is, and then create the cells accordingly.

Usually, i just use an array of whatever object i'm using and then use [array objectAtIndex:indexpath.row], which you probably know about.

Also, you ante-last paragraph has an unfinished sentence that looks important.

Confirming the problem using Xcode 6.3.2 (6D2105) OS X Yosemite 10.10.3 I made sure that the correct value was being assigned, still first time no show, second time show. cell.layoutSubviews() seemed logical to me since it appeared as if the view lacked a refresh and adding layoutSubviews() did the trick.

I had a similar problem with a static UITableView. I change a label's text and it doesn't get updated on the screen unless I clicked on the cell or did anything to force update its views. My workaround was to call after updating the text:

tableView.reloadData()

P.S This doesn't make any sense; because this is a static table view, and I don't know why it worked, but it did!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!