Skip to content

选择一个视频,直接进入视频编辑页,发现很容易崩溃, 笔刷无法使用,贴纸业也无法使用 #855

@gybin02

Description

@gybin02

func makeUIViewController(context: Context) -> UIViewController {
PickerConfiguration.imageViewProtocol = SDImageView.self

    let editAsset: EditorAsset
    if let image = image {
        editAsset = EditorAsset(type: .image(image), result: nil)
    } else if let videoURL = videoURL {
        editAsset = EditorAsset(type: .video(videoURL), result: nil)
    } else {
        // 如果没有媒体文件,返回一个空的控制器
        return UIViewController()
    }
    
    var editorConfig = EditorConfiguration()
    
    // 配置编辑器
    configureEditor(&editorConfig)
    
    // 直接使用闭包回调
    let editorVC = EditorViewController(
        editAsset,
        config: editorConfig,
        finish: { asset, editor in
            HXPhotoEditorView.extractEditedMedia(from: asset, editor: editor) { result in
                DispatchQueue.main.async {
                    context.coordinator.parent.onCompletion(result)
                }
            }
        },
        cancel: { editor in
            DispatchQueue.main.async {
                context.coordinator.parent.onCompletion(nil)
            }
        }
    )
    
    let navController = UINavigationController(rootViewController: editorVC)
    return navController
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions