How can I link an outlet from a view controller to an other? - ios

I am working on an app that uses parse so I used the "starter project" as a base and worked from there.
The issue I am facing is that the ViewController is controlling the login screen a well as others such as the tableView and mapView witch I added later.
As this is the case if it would be possible I would link the map outlet by simply dragging from the code to the map but obviously this is not possible, How could I solve this problem (I understand I may be looking at the problem the wrong way but any help would be appreciated)
here is the code with the map outlet
here is what the layout looks like

The MVC model, Model-View-Controller model, isn't intended to have an action in one view touch the controller of another view. In InterfaceBuilder, you should only ever be able to attach actions to the controller for that specific view.
In general, if you set the file owner to ViewController, then you can only link IBoutlets to that view controller not make to another one.
your map is available in your MapViewController not ViewController, so you need to give the reference/IBoutlet of map need to assign the MapViewController, if you want to implement in ViewController, you need to create new one map

No you have to create different file for each controller.
you cant add outlet of all in one controller

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.

Accessing a ViewController's subview that's added on the storyboard

Please see the image below for a storyboard visual. I have a ViewController called StudioViewController (It's labeled ViewController on the storyboard). And I have a UIScrollView that's called CanvasViewController (the thing to the right of the view controller that actually sits on top of the View Controller). I want to be able to access the CanvasViewController in the StudioViewController class, how do I do that? Because I created it in the storyboard here, I dont' seem to have a variable that allows me to access the CanvasViewController... Should I create it in code instead, or is there some obvious way to access it that I'm completely missing?
Thanks
******** UPDATE *********
The question has been answered in the comments below by rdelmar:
You could make a shared variable in the app delegate. This is not very secure but I have resulted to this when I can't access a child or parent due to page transitions.

IOS Why does a view have 2 Custom Classes?

Probably quite a simple question but I have not seen it addressed so far (I am a ios newbie)
So I start Xcode and create a simple (leave it Blank) view controller in Storyboard.
Click at the bottom so that it highlights in blue allows me to assign that view to a Controller that I am creating.
Thats found under the Custom Class field in xcode
Now if I click anywhere inside that blank view I see that Custom Class reference has changed.
Its now reffering to something else and not my Custom Controller that it was just pointing to.
What is this custom Class a reference to ?
What do I need to use if for ?
Does my view have 2 custom classes associated to it ??
Anyway as you can see I am confused by this.
Thanks !
When you click inside the controller, you're clicking on the controller's view, not the controller itself, so you're seeing its class (which should be UIView if you haven't changed it).

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

One Common View In Every ViewController

I am having a hard time wording this when searching the internet so I am just going to ask the question.
I have an options view in my app that slides into view when the user clicks a button. This options view will display app information like settings. I want this options view to be displayed on every view controller in my app. I do not want to copy and paste the code for the options view into every viewcontroller file. The options view has quite a few outlets and actions and also calls many delegates.
How can I reuse this options view in all my view controllers without adding all the outlets, actions, and delegate methods each time?
I was going to make a new file with public methods, but I would still have to copy the outlets. Would this public methods file have to include delegate methods as well then?
Let me know if my question does not make sense. I am hoping there is a standard way of implementing something like this.
You can just have the options view be the view of an options view controller, and show it modally from any view controller you want. Is there some reason you're not doing it this way? This is the usual way to do this, not by having a view that you reuse in different controllers.
Add the options as a subview of the window, then make your App Delegate handle all of the options view's outlets

Resources