Open nigelgrange opened 11 years ago
Answering my own question... typical :)
I've found this is due to the UINavigationBar frame being zero size, which then gets resized correctly before the view is actually drawn.
Drawing the zero size navigation bar causes the context errors.
I've fixed this by adding:
if (bar.bounds.size.height == 0) {
return;
}
to the top of + (void)renderSizeDependentProperties:(UINavigationBar*)bar
in NUINavigationBarRenderer.m. This works for my app (and style), but I don't know if it is the 'correct' solution.
I was getting this same error, and I traced it back to the
+ (UIImage*)caLayerToUIImage:(CALayer*)layer
method in NUIGraphics.m
Apparently my UISegmentedControl had a frame with dimensions (0,0) that was resized properly after the view was loaded, so UIGraphicsBeginImageContextWithOptions was getting initialized to nil because the frame size was 0, thus the "invalid context" error.
Solution: set the frame size to an arbitrary size greater than 0 in viewDidLoad: Swift:
segmentedControl.frame = CGRectMake(frame.origin.x, frame.origin.y, 300.0, 35.0)
As for an official fix, the frame should be checked for invalid size and either give a warning and return or set the frame based on a height/width property.
I have a number of errors which get reported on the console when my app starts: