ios - Creating an image format with an unknown type is an error in swift, check my below code -
i choose photos photo library, unable photo in table view. got error: [generic] creating image format unknown type error
extension editprofileviewcontroller: gmpickerdelegate { func gmpicker(_ gmpicker: gmpicker, didselect string: string) { self.genderstr = string self.tableview.reloaddata() } func gmpickerdidcancelselection(_ gmpicker: gmpicker) { } fileprivate func setuppickerview() { picker.delegate = self picker.config.animationduration = 0.5 picker.config.cancelbuttontitle = "cancel" picker.config.confirmbuttontitle = "confirm" picker.config.contentbackgroundcolor = uicolor(red: 253/255.0, green: 253/255.0, blue: 253/255.0, alpha: 1) picker.config.headerbackgroundcolor = uicolor(red: 244/255.0, green: 244/255.0, blue: 244/255.0, alpha: 1) picker.config.confirmbuttoncolor = uicolor.black picker.config.cancelbuttoncolor = uicolor.black } } class editprofileviewcontroller: uiviewcontroller, uitableviewdelegate, uitableviewdatasource,uipickerviewdelegate,uiimagepickercontrollerdelegate, uinavigationcontrollerdelegate,uiactionsheetdelegate{ var picker = gmpicker() let pickerbgview = uiview(frame: cgrect(x: 0,y: 0,width: 30,height: 250)) var pickerview = uipickerview() var addressrecord = [string]() var image1 = uiimage() let imagepicker: uiimagepickercontroller! = uiimagepickercontroller() override func viewdidload() { super.viewdidload() tableview.register(uinib(nibname: "roundimgcell", bundle: nil), forcellreuseidentifier: "cellimg") pickerview.frame = cgrect(x: 0,y: -20,width: self.view.frame.width,height: 250)//uipickerview(frame: cgrectmake(0,20,self.view.frame.width,250)) pickerview.delegate = self pickerbgview.backgroundcolor = uicolor.yellow let toolbar = uitoolbar(frame: cgrect(x: 0,y: 0,width: self.view.frame.width,height: 40)) toolbar.barstyle = .black let donebutton = uibarbuttonitem(title: "done", style: uibarbuttonitemstyle.done, target: self, action: #selector(editprofileviewcontroller.doneaction)) donebutton.tintcolor = uicolor.white let space = uibarbuttonitem(barbuttonsystemitem: .flexiblespace, target: self, action: #selector(editprofileviewcontroller.doneaction)) let cancelbutton = uibarbuttonitem(title: "cancel", style: uibarbuttonitemstyle.done, target: self, action: #selector(editprofileviewcontroller.cancelaction)) cancelbutton.tintcolor = uicolor.white pickerbgview.addsubview(toolbar) pickerbgview.addsubview(pickerview) toolbar.setitems([donebutton,space,cancelbutton], animated: true) imagepicker.delegate = self } func pickerview(_ pickerview: uipickerview, numberofrowsincomponent component: int) -> int { return self.addressrecord.count } func pickerview(_ pickerview: uipickerview, titleforrow row: int, forcomponent component: int) -> string? { return self.addressrecord[row] } public func tableview(_ tableview: uitableview, didselectrowat indexpath: indexpath) { if indexpath.row == 0 { uploadimagemethod() } } func uploadimagemethod() { let actionsheetcontroller: uialertcontroller = uialertcontroller(title: "action sheet", message: "now! choose option!", preferredstyle: .actionsheet) let cancelaction: uialertaction = uialertaction(title: "cancel", style: .cancel) { action -> void in //just dismiss action sheet } actionsheetcontroller.addaction(cancelaction) //create , add first option action let takepictureaction: uialertaction = uialertaction(title: "take picture", style: .default) { action -> void in if (uiimagepickercontroller.issourcetypeavailable(.camera)) { if uiimagepickercontroller.availablecapturemodes(for: .rear) != nil { self.imagepicker.allowsediting = false self.imagepicker.sourcetype = .camera self.imagepicker.delegate = self self.imagepicker.cameracapturemode = .photo self.present(self.imagepicker, animated: true, completion: {}) } else { print("rear camera doesn't exist.") } } else if (uiimagepickercontroller.issourcetypeavailable(.photolibrary)) { self.imagepicker.sourcetype = .photolibrary self.imagepicker.delegate = self self.present(self.imagepicker, animated: true, completion: {}) } } actionsheetcontroller.addaction(takepictureaction) //create , add second option action let choosepictureaction: uialertaction = uialertaction(title: "choose camera roll", style: .default) { action -> void in self.imagepicker.sourcetype = .photolibrary self.imagepicker.delegate = self self.present(self.imagepicker, animated: true, completion: {}) } actionsheetcontroller.addaction(choosepictureaction) //present alertcontroller self.present(actionsheetcontroller, animated: true, completion: nil) } func imagepickercontroller(_ picker: uiimagepickercontroller, didfinishpickingmediawithinfo info: [string : any]) { print("select below") if let image = info[uiimagepickercontrolleroriginalimage] as? uiimage { //imagepost.image = image //updated // image1.image = image print("picked") print(image) } else{ print("something went wrong") } self.dismiss(animated: true, completion: nil) } }
error:
platforms/iphonesimulator.platform/developer/sdks/iphonesimulator.sdk/system/library/privateframeworks/assetslibraryservices.framework/assetslibraryservices (0x12140acc0) , /applications/xcode.app/contents/developer/platforms/iphonesimulator.platform/developer/sdks/iphonesimulator.sdk/system/library/privateframeworks/photolibraryservices.framework/photolibraryservices 1 of 2 used. 1 undefined. [generic] creating image format unknown type error
Comments
Post a Comment