How do I open the .swift file for ViewController below, on the left?
I'm ultimately following
question for how to access text in UITextField
but don't know how to open the ViewController to do it.
Just press the button at the right inspector.
In case you deleted or renamed that view controller, you should rename the class of the respective view controller in storyboard.
Related
I am trying to add an outlet for a button, but when I control drag the button into the viewController class, it only allows me to create an action. In the screenshot you can see that the connection type is grayed out and stuck on action. Why isnt it letting me add an outlet? this same issue happens for every object like labels and text fields.
It is probably because you need to connect the storyboard vc to the file.
Click on the storyboard vc -> Click tab on right -> Enter name of view controller file into Class (Where it is highlighted in the image)
When I try to link the UIButton object to the ViewController class in order the create an IBAction, Xcode doesn't show me the window for creating it.
I have to say that It only happens with the second ViewController of the NavigationController, because with the first one it works.
I believe it should be a Xcode bug...
The situation is the one below:
In order for CTRL-drag to work, the ViewController must be told which ViewController class to use.
Once that is done, you can use split view and Control-drag from the button to the code. Xcode will not let you Control-drag to the wrong file.
You cannot control-drag from a button on View Controller 1 to the class file for View Controller 2.
I'm not sure if I see it all in the right way, but you have code for one view controller, which is called ViewController. In this view controller you have an action method for the button via avanti and an action method for the button via indietro. However, the buttons are not in the same scene of your story board. You have the first scene with the button via avanti linked with the ViewController.swift file (Controller initial scene), but the second scene (Controller finale scene) is not linked to your the ViewController.swift file, which it shouldn't. You have to create a new view controller file for every scene in your storyboard and put the action methods in the view controller files that are linked with the appropriate scene. It is also preferable not to call your view controller swift files ViewController.swift, but give them a meaningful name.
Hope this helps.
Kind regards,
MacUserT
the thing you are trying to add is the self.view which is already added in UIViewController Class. try adding another control like button or another UIView
Hi i'm just a bit confused on the linking things from the storyboard to the ViewController.h. I've created a new single view application project and when I went to the storyboard I made a button. Now I went to the editor view and ctrl-draged the button onto my ViewController.h which worked. But when i created another view controller on the storyboard with a button on it, ctrl-drag does not work anymore. I've tried typing in myself, -(IBAction)test:(id)sender;, but it wouldn't let me connect to the button on my second view controller.
You did not set your class name in the VC settings.
I am working on one view controller which has three static screens which i m going to show to user for first time when he installs the app, for next time forever i will show him main functional view.
Problem is
When i have created viewController class i never selected xib option.
Now i have added two xib's (iPhone and iPad) in project.First i deleted the present view from it then I have created three static views in each which contains some label and one button in each..
I want to add those views in my view controller's view. and i want to add targets for buttons in those view.
I am unable to reference outlets in my class for all three views
and can't add target for buttons in my viewController.
How can i do that??
Please help......
Solved it..:)
Problem was when i have added new xib file to project.i deleted the present view controller view from xib...thats why xib was unable to find any of the projects view controllers in custom class drop down
When you click on the File's owner on the left while the XIB is opened:
Select the the third icon on the far right, and make sure the correct class is selected under Custom class, the green textfield:
You need to select File Owner then go to the identity inspector in right pan of Xcode where you can select yor Xib name :)
I've got a Table View Controller object in my Storyboard, but I've made it a custom class called StaticDetailViewController, which I created as a subclass of UITableViewController.
However, when I go to drag from the view to the .h file in the Assistant view, no connection option appears. Why is this?
You have to open and close your curly braces for your #interface in the .h file. For some reason it won't let you control drag using the assistant editor unless you do so... (screenshot)