我正在尝试打开选择器文件菜单。为此,我创建了一个类,如下所示:
class pickerView: UIDocumentPickerViewController, UIDocumentPickerDelegate, LTHM_Pickerable {
func importTapped() {
//Create a picker specifying file type and mode
let documentPicker = UIDocumentPickerViewController(documentTypes: [String(kUTTypePNG)], in: .import)
documentPicker.delegate = self
documentPicker.allowsMultipleSelection = false
documentPicker.modalPresentationStyle = .fullScreen
present(documentPicker, animated: true, completion: nil)
}
public func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
guard controller.documentPickerMode == .import, let url = urls.first, let image = UIImage(contentsOfFile: url.path) else { return }
controller.dismiss(animated: true)
}
public func documentPickerWasCancelled(_ controller: UIDocumentPickerViewController) {
controller.dismiss(animated: true)
}
}
我想在从 UITableViewCell 继承的类中调用函数“importTapped”。
class LTHM_Sticker_Cell: UITableViewCell {
@IBAction func createStickerOnTAp(_ sender: UIButton, forEvent event: UIEvent) {
//CALL IMPORTTAPPED HERE
}
}
你能帮我么?我尝试过使用协议,但我不确定......