Reputation: 35
Let me preface by saying that I haven't worked on any Xcode projects on this machine before. I normally work on a computer at my school, but I'm using another as I am away right now.
I was following along with a tutorial video from a Swift course that I'm taking, but I quickly realized that Xcode isn't giving me the option to connect any outlets. If I attempt to connect a UITextField, it only gives me the option to connect an action. If I attempt to connect a UILabel, it won't give me any options at all. I am used to being given the option to connect Outlets, Outlet Connections, and Actions on a UITextField (and UIButton) and being given the sole option of Outlet on a UILabel.
I've tried to fix the issue by setting the 'class' of the ViewController, but I didn't find any options for that.
Any advice would be greatly appreciated!!
attempting to connect UITextField Outlet
attempting to connect UILabel Outlet
UITextField not giving any option other than Action
Github repository - https://github.com/plates-the-one/noOutlet
Upvotes: 1
Views: 415
Reputation: 3312
Sometimes Xcode is picky when a custom class is specified in the storyboard. A workaround is to write the @IBOutlet
manually and the connect it to the UI element in the storyboard
Upvotes: 0
Reputation: 535925
My guess is that you are attempting to do all this in the wrong storyboard. Work in Main.storyboard, not in LaunchScreen.storyboard.
Also it is crucial that you select the Identity inspector in the storyboard and change the Class from UIViewController to ViewController.
Upvotes: 1
Reputation: 164
I think when you are drawing a outlet, must be some issue with the type
.
When you see the below outlet connection
popup, change the type of the view from Any to the respective UIView
type(UITextField
and UILabel
in your case)
Don't forget to change the connection
from Action
to outlet
after you have changed the type
This must solve your issue. Comment if it solves your problem
Upvotes: 1