views:

56

answers:

2

I am toying with the idea of creating a iPhone UI editor that isn't Interface Builder! Mostly to see if it is possible to do... I have been able to link to the UIKit.framework in a Cocoa app that I have created by dynamically loading it (via NSBundle functionality). I have been able to instantiate an UIView from there. Now the question is... how do I get to whatever the UIView renders?

I am trying to figure out how Apple implemented their Simulator since it seems likely that they are using the frameworks under the iPhoneSimulator.platform folder to do the rendering and then displaying that in a Cocoa window...

I am not sure how far I can go with this idea..but if anyone has any ideas how to direct the output of the UIVIew to a bitmap then I could take that and display in my Cocoa window...

Thanks,

Peter

+1  A: 

You might try making an NSView subclass that hosts a UIWindow. In the NSView's drawRect:, apply any necessary transformations, then send drawRect: to the UIWindow.

Then, set your simulator NSWindow's content view to an instance of that subclass.

Peter Hosey
A: 

Peter,

thanks for your reply. I did try to host a UIWindow in a NSView like you suggested but ran quickly into problem. When I set the contentView of the UIWindow to a UIView that I want to display there is a EXC_BAD_ACCESS way down in CALayerGetSuperLayer (forgotten exactly the error)...

I thought that the Simulator and Interface Builder uses the supplied Simulator frameworks when they were drawing the iPhone UI but now I am not sure anymore. When I dynamically load the UIKit.framework for instance it works...but it complains that a lot of CoreAnimation classes are already defined. That problem lies in the fact that my Cocoa app links in the QuartzCore for the Mac and UIKit.framework links in the QuartzCore for the iPhone Simulator (and they are not the same)..

mobbe