This started to happen out of the blue. Any ideas: Code:
CUSTOMCLASSNAME (I have replaced the actual class name as it contains the name of the client.)
Initialis
I worked this out after a few days. In my custom cell I had a textView, when I was adding it to the contentView I was doing this:
[self.cellTextView setClearsOnInsertion:YES];
This was the cause of the issue; incase anyone else has a similar problem.
Happy coding :-)
In my case, this error was presented only on iPhone (not iPad) because I had placed [self.tableView beginUpdates];
and later [self.tableView endUpdates];
inside [UIView transitionWithView:duration:options:animations:compeletion];
. To fix, I just removed begin/end updates, as I preferred a fading animation instead of fading plus animating cell height changes.
I had the same issue. This message appears when I scroll and cells are reused.
A lot answers talked about viewForHeaderInSection but I didn't use them. In case someone has the similar problem, I hereby show my solution.
I added observer to the textfields inside each cell. I wonder whether this is the observer that caused this issue as I didn't remove the observers when a cell is recycled.
So I removed the observer when a cell is deinited.
It seems the problem is solved. I cannot guarantee.
I found this warning during my viewForHeaderInSection
implementation.
This is my solution in Swift 2.x:
let headerView = self.tableView.dequeueReusableCellWithIdentifier("MyCell") as! MyCell
let containerView = UIView(frame:headerView.frame)
headerView.autoresizingMask = [.FlexibleWidth, .FlexibleHeight]
headerView.myLabel.text = "section title 1"
containerView.addSubview(headerView)
return containerView
This is the Swift 3 version:
let headerView = self.tableView.dequeueReusableCell(withIdentifier: "MyCell") as! MyCell
let containerView = UIView(frame:headerView.frame)
headerView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
headerView.myLabel.text = "section title 1"
containerView.addSubview(headerView)
return containerView
I received the same error, but for a different reason.
I had a custom UITableViewCell that set one of the UITextField's to becomeFirstResponder. The error occurred when more than one instance of this custom cell was being returned.
I simply set only the first instance of the custom cell to becomeFirstResponder and it resolved the issue.
I have just tracked down a cause of this error message.
A UITableViewCell
was being used as a normal view. Therefore its' indexPath
was not set. In our case one was being returned by viewForHeaderInSection
:
Hope this helps.
Chris