这是我的代码:
class signUpVIEwController: UIVIEwController,UIPickerVIEwDataSource,UIPickerVIEwDelegate,UINavigationControllerDelegate,UIImagePickerControllerDelegate {func imagePickerController(picker: UIImagePickerController,dIDFinishPickingImage image: UIImage!,editingInfo: [NSObject : AnyObject]!) { print("Image Selected") self.dismissVIEwControllerAnimated(true,completion: nil) profileImageVIEw.image = image}@IBAction func importimage(sender: AnyObject) { var image = UIImagePickerController() image.delegate = self image.sourceType = UIImagePickerControllerSourceType.Photolibrary image.allowsEditing = false self.presentVIEwController(image,animated: true,completion: nil)}}解决方法 它绝对支持横向模式.把这个扩展放在某个地方.最好在名为UIImagePickerController的文件SupportedOrIEntations.swift中
extension UIImagePickerController{ public overrIDe func supportedInterfaceOrIEntations() -> UIInterfaceOrIEntationMask { return .Landscape }}
这使得所有UIImagePickerControllers都在您的应用程序环境中.您也可以对其进行子类化并覆盖此方法,以仅使子类具有横向能力:
class LandscapePickerController: UIImagePickerController{ public overrIDe func supportedInterfaceOrIEntations() -> UIInterfaceOrIEntationMask { return .Landscape }}
最后,为了支持所有方向,您可以返回
return [.Landscape,.Portrait]
对于Swift 3:
extension UIImagePickerController { overrIDe open var shouldautorotate: Bool { return true } overrIDe open var supportedInterfaceOrIEntations : UIInterfaceOrIEntationMask { return .all }}总结
以上是内存溢出为你收集整理的ios – 在Swift 2.0中以横向模式使用UIImagePickerController全部内容,希望文章能够帮你解决ios – 在Swift 2.0中以横向模式使用UIImagePickerController所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)