Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
558 views
in Technique[技术] by (71.8m points)

iphone - What causes this error? "CALayer position contains NaN: [240 nan]"

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

(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:

XCode 3.x

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

XCode 4.x

  • CMD-6 (breakpoints navigator.)
  • "+" to add breakpoint (lower left.)
  • Select ADD SYMBOLIC BREAKPOINT.
  • Symbol: NSLog
  • Confirm: Done.

XCode 5.x - 7.1 (at least) (Same as 4.x, except breakpoints navigator is CMD-7, now.)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...