我确定这个问题已经得到解答,但我不知道它会如何措辞,所以请耐心等待,显然我有很多关于使用库的知识,因为这是我的第一次。我下载了一个带有pod install的库,现在我正在尝试编辑它中的一个类,但是我添加的函数没有暴露给我在pod文件之外的代码。请注意,pod附带了许多其他文件,但是我找不到对这个类的其他公共变量的任何引用,所以我不确定它们是如何暴露给我的外部代码而是我正在创建的函数(它真正明显命名的不是)。请帮帮我
import UIKit
@objc public protocol WDImagePickerDelegate {
@objc optional func imagePicker(imagePicker: WDImagePicker, pickedImage: UIImage)
@objc optional func imagePickerDidCancel(imagePicker: WDImagePicker)
}
@objc public class WDImagePicker: NSObject, UIImagePickerControllerDelegate, UINavigationControllerDelegate, WDImageCropControllerDelegate {
public var delegate: WDImagePickerDelegate?
public var cropSize: CGSize!
public var resizableCropArea = false
public func myCustomFunctionAddedAfterPodInstall(){
print("hello world")
}
override public init() {
super.init()
print("WD was installed")
self.cropSize = CGSize(width: 320, height: 320)
_imagePickerController = UIImagePickerController()
_imagePickerController.delegate = self
_imagePickerController.sourceType = .photoLibrary
}
}
答案 0 :(得分:0)
我发现XCode不会自动完成该自定义功能,它甚至提供了一个"没有这样的功能"我构建并运行它之前的错误。然而,一旦我这样做,一切都很好。这是我的代码:
WDImagePicker.swift:
@objc open class WDImagePicker: NSObject, UIImagePickerControllerDelegate, UINavigationControllerDelegate, WDImageCropControllerDelegate {
open var delegate: WDImagePickerDelegate?
open var cropSize: CGSize!
open var resizableCropArea = false
public func myCustomFunctionAddedAfterPodInstall(){
print("hello world")
}
...
}
在我的ViewController中:
override func viewDidLoad() {
super.viewDidLoad()
imagePicker = WDImagePicker()
imagePicker?.cropSize = CGSize(width: 280, height: 90)
imagePicker?.delegate = self
imagePicker?.myCustomFunctionAddedAfterPodInstall()
self.present((imagePicker?.imagePickerController)!, animated: true, completion: nil)
}