提问人:BraveEvidence 提问时间:4/15/2023 更新时间:4/15/2023 访问量:108
RCTPresentedViewController 未打开 UIImagePickerController
RCTPresentedViewController does not open UIImagePickerController
问:
我正在尝试使用 for 打开相机应用程序react native's new architecture
UIImagePickerController
iOS
我已经编写了代码,我通过swift
objective-c
这是我的代码objective-c++
#import <Foundation/Foundation.h>
#import "RTNMyCamera.h"
#import "myapp-Swift.h"
@implementation RTNMyCamera
RCT_EXPORT_MODULE()
MyCamera *myCamera = [[MyCamera alloc] init];
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
(const facebook::react::ObjCTurboModule::InitParams &)params
{
return std::make_shared<facebook::react::NativeMyCameraSpecJSI>(params);
}
- (void)takePhoto {
[myCamera takePhotoFromCamera];
}
@end
我的文件中的下一个swift
import Foundation
import Photos
import React
@objcMembers class MyCamera: NSObject,UINavigationControllerDelegate,UIImagePickerControllerDelegate {
let presentedViewController = RCTPresentedViewController()
let viewController = UIApplication.shared.windows.first?.rootViewController
func takePhotoFromCamera() {
DispatchQueue.main.async {
debugPrint("1")
let vc = UIImagePickerController()
vc.sourceType = .camera
vc.allowsEditing = true
debugPrint("2")
vc.delegate = self
self.viewController?.present(vc, animated: true)
debugPrint("3")
}
// present(vc, animated: true)
}
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
debugPrint("4")
picker.dismiss(animated: true)
debugPrint("5")
guard let image = info[.editedImage] as? UIImage else {
.........
我尝试使用和,似乎没有任何效果,我在日志中也没有收到错误消息self.presentedViewController?.present(vc, animated: true)
self.viewController?.present(vc, animated: true)
完整的源代码在这里
答: 暂无答案
下一个:iOS 相机崩溃
评论