views:

782

answers:

2

I've seen this happen whenever i rotate a screen that has a UITableView on it. I've found out that it happens inbetween the willRotate and didRotate method calls in UIViewController My co-workers have seen it in other spots as well, usually around rotation. It hadnt started happening until very recently, and we're stumped as to how we should deal with it (google searches don't turn up the error message in its exact form). Has anyone else encountered this that knows what to do about it?

A: 

I've found the problem.

When you reset the frame of a tableview, it calls the delegate method tableView:heightForRowAtIndexPath: for each row in the table so it can recalculate its content size if it needs to. At that point, we do some special handling to return the height, and due to some bad assumptions in our code, we mistakenly returned NaN due to a divide by zero error (the variable we divide by was assumed to never be zero). Making sure that we do not divide by zero here fixed it.

Kevlar
Olie
put some breakpoints in your viewdidload/viewwillappear methods and make sure you're not dividing by zero anywhere accidentally.
Kevlar
+3  A: 

(Decided to take this out of comments and put it as an answer, since I think it's a darned good answer :)

Ha! I had an NaN calculation (div0), too. Key debugging aid: the message in question is output by NSLog(), so set a breakpoint on NSLog() and watch what the OS is doing at that time. For me, it was myUISlider.value = NaN.

To set breakpoint:

  • CMD-SHIFT-Y (debug window.)
  • Breakpoints button.
  • "Double-click for symbol"
  • Type in "NSLog" (no quotes.)

Run app, watch it break on NSLog, check the stack traces.

Olie