Xcode storyboard UIWebView won't load - ios

So all I want to do is create an App that has two pages: one with a button that opens up a UIWebView in the second. It seems simple enough, yet I have spent the past two days trying to figure it out.
I create the object and put in the code for the link and ctr - drag the web-view to the controlview.h but nothing will work.
Does anyone know a tutorial or can explain this to me? I have been searching the web for the pat two days and have gotten nowhere. thank you.

Each "page" should be a separate view controller. You open the storyboard editor, drag a view controller to it, drag a web view to your new view controller, then drag a segue from the appropriate control on the first page to the second page.
You will also need to create a UIViewController class for the second page, and set the controller's identity in the storyboard editor. (Select the second controller, type command-option-3, enter the view controller's class name in the "Custom Class" section.)
In the second view controller you will need some code to make the webview do something, obviously, so you probably will want to create an outlet for the webview.

Maybe you should start out with this general guide on View Controllers. You'll learn how to use View Controllers and how to present Modal View Controllers.
After that you go on with the documentation about UIWebView.
If you do a quick search for UIWebView you'll find tons of tutorials, but basics are important :)

CONTROL+DRAG does not work on storyboard. When I click view and drag to UIWebView, it opens a black popup but I cannot see my web value. I just see "view".
It does not work on storyboard either. I tried it on xib and it works with that.

Related

How do I add code to my viewcontroller.swift for views connected via a navigation controller?

So I am pretty new to Xcode (but not programming in general, have learned a bit of python and java) and I am trying to figure out, for the life of me, how I connect bits of code in other views besides the first one when they are linked from a navigation controller.
To paint a picture of this, I essentially start out with a single view application, I have the first view and I add a button to it and then I embed it in a navigation controller by doing.. Editor -> Embed In -> Navigation Controller. The next time, as I have been following from various guides online, is that I control drag that button to that view and hit "show" to link them. Now say I have another button in that new view I just linked to. Xcode doesn't seem to let me just control drag that button onto the text in viewcontroller.swift, I believe that this is because they are two separate view controllers now however I have not a clue where the second viewcontroller2.swift file may be. Or, maybe, there is an easier way to link the two views together and actually be able to modify the source files?
If you're trying to find a "ViewController2" you won't find it, because you have to create it! Use Command-N to create a new file and choose "Cocoa Touch Class". Name it something like SecondViewController and make sure it's a subclass of UIViewController. Now you can go back to interface builder and change the class of the second view controller to whatever name you just chose, like SecondViewController.
To address the other part of your question (I think), I'm not exactly sure what you're trying to do. If you want some of your data to transfer to the new ViewController, use the prepareForSegue function in the first ViewController.

UICollectionView inside ViewController

Good afternoon,
I would like to implement a UICollectionView inside my ViewController and I'm a little bit lost because I'm trying to read tutorials and find some good guides, but I'm unable to implement it.
I have a UICollectionView created in an another App, and it's using a UICollectionViewController, now I need to put that code inside a ViewController (without the UICollectionViewController), and it's hard for me because it's my first time implementing that view inside a ViewController.
Can you help me with some tutorial, guide or example? I want to know how to do this.
I have followed this tutorial to create the UICollectionView: http://www.techotopia.com/index.php/An_iOS_7_Storyboard-based_Collection_View_Tutorial#Adding_a_Collection_View_Controller_to_the_Storyboard and now I need to put that CollectionView in my "App" where it is going to show the user images, so in my top I'm going to have the username, userpicture, etc, etc and in the bottom I'm going to have the UICollectionView.
Thanks in advance.
In your storyboard, add a "Container View" to "ViewController". This adds a view to the view to the view controller and a "View Controller Scene" to your storyboard with a view controller at the end of "Storyboard Embed Segue". This view controller will control the content shown in the embedded view. Assign the "Custom Class" of the view controller at the end of the embed segue to be your collection view controller.
I am not at my iMac right now, so cannot supply screenshots. Give me a shout if you need them to understand what I trying to describe.

UzysSlideMenu: how to use several view controllers?

I just came across a slide-in menu I really like: https://github.com/uzysjung/UzysSlideMenu
I would like to use this menu for an application that uses several view controllers (UIViewControllers and UINavigationControllers).
In Xcode, I created a single view application and made the view controller (MenuViewController) show the menu, like the creator did in his example project. I added more view controllers to the storyboard and connected them via segues to the MenuViewController. Upon selecting a menu item, these segues are triggered and the selected view is shown - so far so good.
But now, I run into the following problem:
All my view controllers are shown in full screen. That means that VCs that get segue'd in the viewport don't show the menu, because it's just not implemented there. I could put the menu in every VC, but that doesn't seem to be the right way to do it (even if I use some custom delegate method that every controller calls, like putMenuInViewController:(UIViewController *)target). I think I need something like a global singleton for the menu and make it appear in every view controller, but I have absolutely no idea on how to it or what to google for.
Any points into the right direction are greatly appreciated :)
I think you need to implement one root view controller with this menu as singleton, and add other view controller as child view controller to it.
I wrote a post about it, you can find it here:http://antrix1989.blogspot.com/2013/09/uiviewcontroller-as-singleton.html

Mapview in tabbed application in iOS

I would like to ask something, because as a beginner I do not have any idea anymore
how it could work.
First of all I made a new project, a single view one and added a simple map view.
This worked very well (following a tutorial of course)
Now I tried to add this simple map view to my inital project, which is a tabbed based on with navigation controller.
In this tabbed application I already added two more views with view controllers, and I called them thirdview Controller and forthview controller. The vc's I gave the class thirdview and forthview controller.
So, now I wanted to make the mapview on the thirdview. I did exactly what I did in my "trial project" but it is not working. Well, when I run the simulator I see a map. But it does not show the location as I have specified it inn the thirdview controller.m
Because it was working in the singleview project, I guess I have something to add or to connect in my inital tabbed application?
I would be greatful for any help on this
Thanks a lot
What you have there, as I can see from what you say, is a very simple and litle forget made by everyone who begins with xCode :)
Try to link your viewControllers and your map (in the xib or Storyboard) to your file's owner' view and delegate.
by default, these aren't linked. Just right click on it and drag your View and delegate to your file's owner.
Also, be sure that each of your viewControllers' classes are really thirdview and forthview in the properties (don't be confused with xib identifier!)
Hope this helped you! Feel free to ask if anything is missing :)

Two UITabBarControllers sharing one ViewController (as tab content)?

Situation: two UITabBarController's, each with their own tabs, but last tab in both is identical so want one UIViewController to show content.
Issue at runtime: Shared item only appears in one of the tab sets when shown.
Question: anyone know a way to make this work?
Link to external graphic of storyboard setup: (sorry, don't have enough reputation to post images here!)
Storyboard graphic
An Xcode project with that storyboard:
XCode Project
Each tab content item has it's own UIViewController class. They contain no code except the line to make the back buttons work.
(Yes, I know this is odd. Real situation is an iPad app where tab controllers are shown in popovers; popovers are "property editors" where different objects have different properties, but all share a common set of properties... thus one tab for "unique" props, one shared tab content for the "common" props all objects have.)
I've found a couple ways around this to get the effect I want, but if this storyboard worked it would be a much easier solution.
-- Other info, somewhat unrelated to question --
Alternate solution I'm using: TabBarControllers only link to one VC as tab content. When that tab VC loads, I use code to (a) instantiate shared VC from storyboard by identifier, (b) add that new VC object to the TabBarController via [tabController setViewControllers:list animated:NO].
(Another possible solution I like even less: not using a TabBarController, and presenting content VC's with my own "tab" graphic drawn into them, each showing "myself" as selected. Yuk.)
So I have a working solution, I'm just curious as to why this doesn't work (just a known thing in iOS API, or some magical property setting that might render it functional?)
You can't put the same view controller instance into two tab controllers. The problem is that a view (UIView) instance can only have one parent view (superview). When you try to add the view controller to the 2nd tab, the view controller's view gets removed from its first parent (the first tab) and then added to the 2nd tab.
I stumbled upon your thread while running into the same issue today...
The solution is to just make a duplicate of the view controller in story board and attach the duplicate to the other tab bar controller.
I just did it and it works...
I think the 'rdelmar' is right about this... copy it and set it ..!!
I ran across this same issue today. I managed to come up with a workaround that seems to do the trick. The key is to add a layer of separation between the tabbar and the controller you want to reuse. From each tabbar, I created a relationship to a distinct UIViewController with a container view. Then you can do an 'embed' segue from the container to the controller you actually want to reuse as the tab view. It is not quite as clean as a direct connection (not sure why that is not supported) since you do have to create a controller class for each reuse case. It is still a better solution than the nightmare of having to duplicate the actual tab view ( as well as any additional views that connect to it) for every use.
Hope this helps. Let me know if anyone needs more details.

Resources