objective-c - Qt 5.3 中的 UIImagePickerController

标签 objective-c uiimagepickercontroller qt5.3

我想实现 iOS 的应用程序。我用过Qt 5.3Mac 。我想在 Qt 中定义用户界面。我想在 *.ui 上有一个按钮。当点击它时,iOS照片库将打开,然后用户可以选择照片。我知道我必须使用 UIImagePickerController .

我必须使用根 Controller 并在其上显示 UIPickerImageController 。 为此,我需要使用一些内部 Qt API :

首先,在 *.pro :

QT += gui-private

然后,在我的 *.mm代码获取指向 Qt 的 Root View Controller 的指针应用程序:

UIView *view = static_cast<UIView *>( QGuiApplication::platformNativeInterface()->nativeResourceForWindow("uiview",quickView) );
UIViewController* rootCtrl = [[view window] rootViewController];

现在,我可以显示 UIImagePickeController :

[rootCtrl presentViewController:imagePickerController animated:YES completation:nil]

通过这种方式获取 Root View Controller QML ,解决了我的问题,但我不想使用 QML 。是否有另一种方法来获取指向 Qt 的主 Root View Controller 的指针应用程序( C++ + Objective-C )而不使用 QML

谢谢!

最佳答案

您可以使用 UIApplication 和 keyWindow 属性:

UIViewController* rootViewController = [[UIApplication sharedApplication].keyWindow rootViewController];

关于objective-c - Qt 5.3 中的 UIImagePickerController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26560786/

相关文章:

objective-c - 相当于Cocoa中的UIScrollViewDelegate?

objective-c - 如何将 UITableViewController 添加到 XCode4 中 UITabViewController 上的 UINavigationController?

ios - 使用键盘向上移动文本字段

ios - 如何在iOS的自定义图像选择器 View 中进行自动闪光

c++ - 模板中的断点被忽略,有解决方法吗?

objective-c - 尝试在 UIView 中绘制

objective-c - 使用 UIImagePickerController 选择图像后,照片库 View 停留在屏幕上

ios - UIImagePickerController 错误 : Snapshotting a view that has not been rendered results in an empty snapshot in iOS 7

c++ - QButtonGroup setExclusive() 问题

c++ - QtConcurrent 在 reportResultsReady 上崩溃