Cannot find protocol declaration for 'UIWebViewDelegate' - objective-c

I am trying to utilize UIWebView functionality, specifically I want to do something like this: Open links in Safari instead of UIWebVIew?
But I am having an issue when I try and add the UIWebViewDelegate to my AppDelegate interface.
Anyone know what the issue is? Note this is Mac OS not iOS.

Add:
#import <UIKit/UIKit.h>

Anyone know what the issue is? Note this is Mac OS not iOS.
That's the issue right there.
There is no UIWebView or UIWebViewDelegate on MacOS X. UI is the prefix for UIKit, which is the iOS equivalent of AppKit. When you see a class whose name begins with UI, you know immediately that you're looking at iOS code.
The class you're probably looking for is WebView. WebView actually uses five separate delegates, so you may need to implement as many as five different protocols: WebUIDelegate, WebDownload, WebFrameLoadDelegate, WebPolicyDelegate, and WebResourceLoadDelegate. (In reality, I don't think you need to do quite that much work. For example, you may not need to implement your own access policy.)

UIWebView is iOS only. You cannot use a UIWebViewDelegate for Mac OSX. If you look at your own code, you are using a WebView, not a UIWebView.
You'll want to look at the WebView class docs

Related

Xcode objective C: How Clean code from UIWebView (ITMS-90809)

I use Windev mobile to developpe apps for both Android and IOS. For IOS apps, Windev mobile gave me an objective-c project that i should build in xcode then send to app store ..
I'm know only basics of basics step on xcode and i need to clean my code from "UIWebView", I have seen more than discussion about that but none of them repond to my case ..
For exemple thay talk about using: grep -r UIWebView project path .
But i realy dont know how to use that ...
Please your help will be very very appreciated !
Thanks!
Really just some guidance - how to do it actually depends on your situation.
Don't use grep - just use your IDE's search to locate all the UIWebView and then replace them with WKWebView. It can be as simple as that depending on what you use your webview's for. If for complex processing then you'll need to figure out how to do what you did in UIWebView in the WKWebView.
Another suggestion - why not wrap all your UIWebViews in some custom class and move all the functionality in there. Then it is easy to replace the UIWebView there and also rework the functionality there with the class staying the same. Apart from the functionality you'll have code that looks something like this in there.
+ ( UIWebView / WKWebView * ) addWebViewToView:( UIView * ) view
{
// Code to create webview - initially UIWebView and later WKWevView
..
// Code to embed the webview into the view
.. set the constraints to fill the view
return webview;
}
Then you can use normal UIView's in your project and use this to prime them with a webview.
To this you can later add navigation delegates to beef up the functionality or, if you just use the webview to display some HTML, you can pass in the string or URL to display.

How to use NSLayoutConstraint in iOS 6?

My app should support both iPhone resolutions (5 and older) using iOS 5 and iOS 6. When I use autolayouts in IB, on iOS 5 app crashes like this: link
So, I am trying to use NSLayoutConstraint in code, but unsuccessfully yet.
Subquestions:
I am adding constraints in viewDidLoad method, but is it correct?
Does updateViewConstraints invoke by framework? I have never seen that it was invoked.
I tried to use examples from apple's docs, but it was without effect to view.
Anybody knows how to do it?
PS: I know it's possible to make it manually by setting frames, but I would like to use NSLayoutConstraints.
UDP: Yes, I know, that's why i use NSLayoutConstraint in code. I can make condition for determining iOS version. The question is about iOS6.
The AutoLayout feature is only compatible with iOS6 and is not supported in iOS5. Thus the crash
If you intend your app to be compatible with iOS5, you can't use AutoLayout in your XIB files.
You can only use older methods, like the AutoResizingMask for example (which is often sufficient for most cases anyway).

ZBar SDK Embed Reader with Storyboards

I'm trying to use the ZBar SDK to create an embedded QR Code reader just like shown in the example here: https://github.com/twotoasters/zbar (the Embeded Reader example)
The only difference is that I'm using it in storyboards. I tried copying the code into my application and everything seems to be fine, until I actually try to use it.
I'm working on a simulator, so the ZBarCameraSimulator is initializing and showing it's text, but when I try the "two finger click" (checked the Multitouch Option in the Subview attributes) it seems to ignore the action.
I guess there is a delegate or a handler missing, which was not required in with XIBs but is necessary within the Storyboards.
Anybody got any clues? Would be thankful.
Ok, looks like I found the solution,
I was assuaging the readerView to a (weak, nonatomic) IBOutlet property, while the XIB project used "retain" option. I changed the option to strong (as what I understand from ARC, retain shouldn't be used with it) and it started working.
I am also using this with storyboard and have had no trouble having the simulator recognise the two finger click. I do this by pressing Option+Mouse and holding it for a second.
I do however have follow on issues where the scanned image does not seem to be processed, but I think that my be due to a delegate issue.

AVFoundation documentation codes

I am reading Apple documentation regarding AVFoundation framework. I want a NSView in my Cocoa application to play video in my application. It's a tutorial video something similar to what apple provides in their application.
My question is, while reading this document...
AVFoundation programming guide
Most of the classes mentioned are related to iOS as an example...PlayerView extends from UIView.
Now, before I code I want to ask should if I am making application using same example code for Cocoa App should I read UIView as NSView? is that the solution?
I haven't tried as it's lots of code, I thought it's better to understand it before start coding.
In this specific example you should be ok replacing UIView with NSView with possibly some minor changes, since it seems like a lot of the work is being done on the view's layer, which is a property that exists in AppKit as well as UIKit for NSView and UIIView respectively.
I am not sure what you overall goal is here, but as long as you are not intending to copy the doc line for line, you'll be ok; ie you might need to make small changes.
Hope this helps.
It sounds like you want a simple QTMovieView loaded up with a video to play

Why cant I see the 'UIViewController subclass' under Cocoa touch for ios/macos?

I'm a newbie, and plainly started with a sample code from the book 'Beginning-iOS-5-Games-Development'.
Everything seems quite straight-forward, but i cant see the UIViewController subclass under the Cocoa touch for both ios/macos...
Would this have anything to do with the fact that the example is trying to work with Universal device type.
My Xcode version is 4.3.2, and im trying out ios5...
thanks for your help..
user
You have to select Objective-C class, then click Next. On the next screen, you can specify that the class you are making is a subclass of UIViewController.