0

我正在使用 xcode 7.2 和 Swift 2.1.1。我通过桥接头使用 ELCImagePickerController。当我在类声明中使用 ELCImagePickerControllerDelegate 时,它​​显示错误 - 视图控制器不符合协议 'ELCImagePickerControllerDelegate'

let picker = ELCImagePickerController() picker.maximumImagesCount = 5
picker.delegate = self self.presentViewController(picker, animated: true, completion: nil)

这是我的目标 c 标题#import "ELCImagePickerController.h"

当我在按钮单击事件上使用此代码时,它会进入空视图而不是图库。任何人都可以帮助我克服这个错误。

提前致谢。

4

1 回答 1

1

错误 -视图控制器不符合协议“ELCImagePickerControllerDelegate”,因为您必须实现以下 2 个强制的委托方法。(非可选)

func elcImagePickerController(picker: ELCImagePickerController!, didFinishPickingMediaWithInfo info: [AnyObject]!) {
    
}


func elcImagePickerControllerDidCancel(picker: ELCImagePickerController!) {
    
}

下载整个工作项目

工作代码

import UIKit


class ViewController: UIViewController, ELCImagePickerControllerDelegate {

    var picker = ELCImagePickerController(imagePicker: ())
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
    }

    
    override func viewDidAppear(animated: Bool) {
        
        picker.maximumImagesCount = 5
        picker.imagePickerDelegate = self
        self.presentViewController(picker, animated: true, completion: nil)

        
    }
    
    func elcImagePickerController(picker: ELCImagePickerController!, didFinishPickingMediaWithInfo info: [AnyObject]!) {
        
    }
    
    
    func elcImagePickerControllerDidCancel(picker: ELCImagePickerController!) {
        
    }
   
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

那个黑屏是因为

var picker = ELCImagePickerController()

正确的方法是

var picker = ELCImagePickerController(imagePicker: ())
于 2016-11-29T07:50:40.713 回答