问题
App crashed and log gave me this message:
"Nested optimization should never be triggered. This is probably due to autolayout work happening inside an NSISVariable delegate callback, which is not allowed."
How to fix this?
回答1:
Think I was updating UI in a background thread. Try putting:
if ([NSThread isMainThread]) { NSLog(@"isMainThread"); } else { NSLog(@"isNotMainThread"); } next to UI updating lines, in order to find UI updates in background thread.
Example:
if ([NSThread isMainThread]) { NSLog(@"isMainThread"); } else { NSLog(@"isNotMainThread"); }
_MyLbl.text=@"some text";
if isNotMainThread is shown in log, replace the two lines with:
dispatch_async(dispatch_get_main_queue(), ^{
_MyLbl.text=@"some text";
});
Not really an answer, more of a tip. But better than nothing I guess.
来源:https://stackoverflow.com/questions/44318195/nested-optimization-should-never-be-triggered-this-is-probably-due-to-autolayou