开发者

iPhone - launching an UIImagePickerController from a UIWindow

开发者 https://www.devze.com 2023-04-10 00:50 出处:网络
How may I launch a UIImagePickerController from the main UIWindow (no view defined) from - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions, o

How may I launch a UIImagePickerController from the main UIWindow (no view defined) from - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions, on a proj开发者_StackOverflowect for which the main window does not have a built-in Navigation controller into IB (and without having to add one into IB)?


If you don't need UINavigationController then just place regular UIViewController as a root view for main windows. And present UIImagePickerController from it.

Example:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window.rootViewController = [[[UIViewController alloc] init] autorelease];
    UIImagePickerController *imagePickerController = [[[UIImagePickerController alloc] init] autorelease];
    [self.window.rootViewController presentModalViewController:imagePickerController animated:YES];
    [self.window makeKeyAndVisible];
    return YES;
}


self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];    
[window addSubview:imagePickerController.view];

That should accomplish what you want.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号