Xcode: Cannot create a delegate Outlet - ios

This is an Objective-C app and I'm working with Xcode 14. I'm trying to migrate deprecated UIWebView to WKWebView and I've already replaced all UIWebView references in code by WKWebView, but I'm stuck in the storyboard part (bear in mind I'm new to iOS development).
What I'm trying to do is to add a WKWebView to the SB, then replicate all properties of the current UIWebView and finally remove the UIWebView.
In the following screenshot you'll see in the right pane of the Storyboard that the current UIWebView has a delegate outlet:
But I don't know hot to replicate this delegate outlet in the WKWebView that is below. I have to say I don't k ow what is a delegate in this context exactly, but I'm just trying to replicate properties of the current WebView.
How to create a delegate outlet for the WKWebView?

You can give your WKWebView an outlet connection for an outlet that it actually has. A WKWebView does not have a delegate property. Therefore it does not have a delegate outlet.
What I'm trying to do is to add a WKWebView to the SB, then replicate all properties of the current UIWebView and finally remove the UIWebView.
Well, stop trying to do that. A WKWebView is very different from a UIWebView. You should not look to "replicate" anything about a UIWebView using a WKWebView. Use the WKWebView as a WKWebView.
For one thing, all your code interactions with this view will have to be rewritten completely. You cannot just slot the WKWebView in place of the UIWebView as if they were just two names for the same thing.

Related

Embed a UIView in a WKWebView?

Simple question: Is there a way to display a web page with WKWebView but override one part of it with a native iOS view -- ie, a subclass of UIView.

Web View at the bottom of each UIViewController

I am creating an iOS version of my app. I need a ad banner at the bottom of the app. The banner is just a web view which is showing content from our Server.
In Android app we have created the WebView in activity and shown the pages using fragments. We need the same feature in iOS too, but I am not able to find a proper tool to do it.
I just need a WebView Banner at the bottom of all the ViewControllers. Is there any way to create one WebView Object and add to every ViewController or do I need to create separate WebView for all the UIViewControllers?
You have 2 options for that;
Number-1
You can create just one UIWebViewController and shown it on any other objects and windows even keyboard. All you need is that you have to add your UIWebviewController object to subview of last object of your window like that;
[[[[UIApplication sharedApplication] windows] lastObject] addSubview:yourWebViewController];
Number-2
Use Apple's iAd program. It'll handle that for you.
https://developer.apple.com/iad/
Thanks for the suggestion from tnylee, the ContainerView method worked for me.
I basically created a new UIViewController, added ContainerView at top taking all the space and added UIWebView in bottom. After adding few usual Constraints, I removed the segue to the Main View Controller (Since I had an extra Loading Screen in start.) and moved it to the new ContainerViewController.
Now I just need to add an embed segue from the ContainerView (Not from ViewController) to the Main View Controller.
Here's how this looks in storyboard -

Content area didn't scroll in xamarin side bar component

I'm currently using this component in xamarin
http://components.xamarin.com/view/SidebarNavigation and basically it works fine, but when i try to use a UITableViewController as one of my content and add a lot of items in tableview that will basically make the app scroll, the app didn't actually scroll when you run it to iOS simulator, I haven't add any code yet to my contentController and I haven't change any property on my UITableView, just drag a UITableViewController from toolbox set up the code behind controller, storyboard ID, Restoration ID add some data to the tableView then hit run.
I don't know if this is a bug or I'm doing something wrong? any idea everyone? or you can just give me any free component that use as navigation drawer in iOS app.
thanks!
I think it's a bug!
You can solve it by wrapping your uitableview in a uiview.
Just make a fresh view controller and put a tableview as its only child!
Good luck ;)

Simple iOS app to show my site in UIWebView *with* back / refresh controllers

Looking all over for a simple Xcode project that will load my web site in a UIWebView that has the default Safari controllers for back / refresh the page - but can't seem to find one.
All I could find was a great template project, but it didn't have the controllers. And since I am very new to iOS development, I can't figure out how to add the controllers.
Can anyone help me out with complete source for something like that?
Thanks
Add a navigationbar above or a toolbar under the webview
Put two barbuttonitems/buttons into the bar, one for back and one for forward. Of course you can also use the segmented control
Set the webview's delegate to the view controller of the view
In the TouchDown-actions of the buttons, call webView's goBack: or goForward: methods
For the method references, see here: https://developer.apple.com/library/ios/documentation/uikit/reference/UIWebView_Class/Reference/Reference.html#//apple_ref/occ/instm/UIWebView/goBack
The same can of course be done with reload (the method is called refresh), and this SO even shows an example of how to do it:
Refresh a UIWebView

UIWebView IBOutlet Connection issue

So I'm going to try to explain my issue as best I can.
I have 2 View Controllers on a Storyboard. One is the "main" VC and the second is a "EULA" VC.
The main view controller has a UIWebView which loads the primary UI and works fine. This controller uses code to perform a Modal segue to the EULA VC which is created in the interface builder. This also works fine.
Now here lies my problem. The EULA view controller also has a UIWebView on it but I can't seem to connect this view controller to any connection by means of CTRL + drag. The "main" UIWebView is connected to ViewController.h
This is how I create my connection with CTRL + drag:
My question is why am I able to connect the first UIWebView on the Main view controller but not the other UIWebView on the EULA view controller? What am I missing?
Have you set up the EULAViewController.h as the custom class for the ViewController in Interface builder? Select the UIViewContoller in Interface Builder and in the third tab make sure the class is correct. Here is a screenshot explaining what I am saying:
Also make sure you have selected the correct file in the right pane, both red boxes should show the name of your custom UIViewController subclass:
I am think this is a bug in XCode or what. But this is very rare issue. I also got this issue sometime. So posting a solution which can make you little nervous to implement. But it works for me sometimes. You can try it . -
Just create a new UIViewController subclass in your project and name it something slightly different than the first. Then, copy/paste all code from old non-working UIViewController into the new UIViewController subclass (.h and .m) and change all relevant symbols according to the new UIViewController subclass name. After doing this I found everything worked as normal in terms of trying to control-drag wiring the buttons.
Happy coding. :)
Recreating the class files, renaming the view to something else then back to EULAViewController AND following these steps I was able to fix the issue.
Close the project you are working on with.
Delete the【DerivedData】folder of you project. (This folder may
inside your project's folder, or inside
~/Library/Developer/XCode/DerivedData/(your project)/ ) or somewhere
else that were setup by you.
restart you project.

Resources