Last week I demo’d an Adobe AIR native extension that displayed a native MKMapKit view in an AIR application. Here is how to integrate any UIView object.
First you need a reference to the native applications view hierarchy. You can grab that like so:
id delegate = [[UIApplication sharedApplication] delegate]; UIWindow *window = [delegate window];</code></p>
Once you have the window object you can add any sub view to it that you want. Here’s an example of adding a MKMapKit view.
MKMapView *map = [[MKMapView alloc] initWithFrame:CGRectMake(0, 0, 480, 320)]; [window addSubview:map];
That’s it! This code can go pretty much any where in your native extension. Keep in mind that these native views are not part of the AIR application’s display list, so they always render on top of the AIR application.
I’ll demo how to draw a native view to an AS3 BitmapData object in a future post. This allows you to integrate the native views with AIR’s display list, but at the cost of loosing all native interaction.