如何将UIImagePickerController场景呈现为初始场景?

时间:2015-04-09 02:43:04

标签: ios uiimagepickercontroller

我创建了一个UIViewController场景并将其自定义类设置为StoryBookPageImagePickerController但是当我运行该程序并授予对照片的访问权限时,我会看到标题和黑屏,没有可供选择的照片。

class StoryBookPageImagePickerController : UIImagePickerController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {

override init() {
    super.init()
    self.sourceType = UIImagePickerControllerSourceType.PhotoLibrary
    self.mediaTypes = UIImagePickerController.availableMediaTypesForSourceType(.Camera)!
}

required init(coder aDecoder: NSCoder) {
    super.init(coder: aDecoder)
}

override func viewDidLoad() {
    self.delegate = self
    println("Loaded image picker")

}

//MARK: Delegates
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject : AnyObject]) {

}
func imagePickerControllerDidCancel(picker: UIImagePickerController) {

}

}

1 个答案:

答案 0 :(得分:0)

抱歉,你不能继承UIImagePickerController的子类。来自文档:

重要

UIImagePickerController类仅支持纵向模式。此类旨在按原样使用,不支持子类化。此类的视图层次结构是私有的,不得修改,但有一个例外。您可以将自定义视图分配给cameraOverlayView属性,并使用该视图显示其他信息或管理相机界面与代码之间的交互。