迅速。传递UIImagePicker的委托作为参数

时间:2015-10-21 19:43:18

标签: swift delegates uiimagepickercontroller

ImagePicker类包含和UIImagePicker:

tx2

UICollectionView进入图像选择器:

if (!tx2.IsEnabled)
{
    tx2.MoveFocus(new TraversalRequest(FocusNavigationDirection.Next));
};

因为上面提到的错误,这不起作用,但我该怎么做?

1 个答案:

答案 0 :(得分:2)

委托不能是AnyObject?类型。它必须是protocol<UIImagePickerControllerDelegate, UINavigationControllerDelegate>?类型:

class ImagePicker {
    let imagePicker = UIImagePickerController()
    weak var delegate: protocol<UIImagePickerControllerDelegate, UINavigationControllerDelegate>?

    init(delegate: protocol<UIImagePickerControllerDelegate, UINavigationControllerDelegate>?) {
        self.delegate = delegate
    }
    ....
}

您还应该将其设为weak属性以避免保留周期。