iPhone - 从 UIWindow 启动 UIImagePickerController

发布于 2024-12-07 08:57:34 字数 231 浏览 0 评论 0原文

如何从 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 的主 UIWindow (未定义视图)启动 UIImagePickerController主窗口没有内置导航控制器进入 IB 的项目(并且无需向 IB 添加导航控制器)?

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

她比我温柔 2024-12-14 08:57:34

如果您不需要 UINavigationController,那么只需将常规 UIViewController 作为主窗口的根视图即可。并从中呈现 UIImagePickerController 。

例子:

- (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;
}

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;
}
七分※倦醒 2024-12-14 08:57:34
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];    
[window addSubview:imagePickerController.view];

这应该可以实现你想要的。

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

That should accomplish what you want.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文