Creating an Image Format with an Unknown Type Is an Error Objective-C Xcode 8

Creating an image format with an unknown type is an error with UIImagePickerController

Below mentioned code did solve the problem for me -

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) {
if let image = info[UIImagePickerControllerOriginalImage] as? UIImage {
imagePost.image = image
} else{
print("Something went wrong")
}

self.dismiss(animated: true, completion: nil)
}

Creating an image format with an unknown type is an error when displaying a WebApp through WKWebView

Creating an image format with an unknown type is an error this is a generic warning you can safely ignore the warning. The problem should be something else.

import UIKit
import WebKit
class ViewController: UIViewController {
var webView:WKWebView!
override func viewDidLoad() {
super.viewDidLoad()
loadWebView()
}

func loadWebView(){
webView = WKWebView(frame: self.view.frame)
self.view.addSubview(webView)
let urlRequest = URLRequest(url: URL(string: "https://imgbb.com/")!)
webView.load(urlRequest)
}
}

I created a webview and tried to upload an image from photo library. it does give me that warning but it successfully uploaded the pic from photo library. You can try to above code and see if it works for you. btw don't forget to add permission explanation to access photolibrary in info.plist

result

Unknown type name 'UIImage'

I also had the same problem and fixed it using

#import <UIKit/UIKit.h>

However, I dug around some more and compared a project made in XCode 6 compared to Xcode 5, and I noticed that Xcode 6 did not create a prefix header file. The prefix header file is implicitly imported into every class, and the prefix header file (.pch) includes UIKit as well as Foundation.

To create a pch file, go to File -> New -> File -> Other -> PCH file. Edit the name to "YourProject-prefix.pch". Add the following:

#ifdef __OBJC__
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#endif

Then you need to set the build settings. Go to your project -> build settings -> search at the top: prefix header.

You will see Precompile Prefix Header -> change to yes.
Also, right below is Prefix Header. Add the path of your prefix header. Should be like: "YourProject/YourProject-prefix.pch".

iOS 8 Expected a type

If you check the docs for UIImage you'll see it's in UIKit, not Foundation. The docs are now all targeted at Swift, which is somewhat annoying, but you'll see the import statement in the docs is specified as

@import UIKit;

which you need at the top of your file (no need for the Foundation import either).

Sometimes projects include this import statement in a precompiled header file (pch). This should be referenced in Build Settings->Prefix Header, or it won't be used in compilation.



Related Topics



Leave a reply



Submit