1
votes

I'm working on an app with the main view being a UITabViewController. Under the UITabViewController are three UIViewControllers and one UITableViewController. Under one of the UIViewControllers is a UIView and an NSObject which conforms to NSXMLParserDelegate. Here's an outline of the structure at a high level: AppDelegate: UIResponder UIViewController1 & xib UIViewController2 & xib UIViewController3 & xib UIView (CG calls are here) NSXMLParser UITableViewController & xib

The xib of the UIViewController has a outlet to the UIView. An instance of the UIView is alloc'd and init'd in the UIViewController. The UIView then alloc's and init's the NSXMLParser, loads the data, does the drawing, and executes [self setNeedsDisplay]. The app compiles without errors and I've verified the XML data is being loaded and parsed correctly.

The problem is that drawRect: in the UIView is called when the UIView is init'd, but never again. The data is not yet loaded when drawRect: is called, so nothing is drawn. I've verified that [self setNeedsDisplay] is being called, but drawRect: is never called again.

Anyone have any idea why drawRect: only gets called once? Thanks.

1

1 Answers

0
votes

Do you have some code running, perhaps relating to your XML parser, that's blocking the main thread? If so, UI updates won't happen until the next iteration of the run loop.

You can force an iteration of the run loop by calling:

[[NSRunLoop currentRunLoop] runMode: NSDefaultRunLoopMode beforeDate: [NSDate date]];

More information can be found at this answer.