Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'd like to create a basic view controller class BasicController with two subclasses SubclassController and AnotherSUbClassController. BasicController controls view that have a button inside them, so there should be a

weak var buttonThing: UIButton? 

property in it. In the actual implementation I want to use the subclasses in various parts of the interface: I want to draw them in storyboard, put buttons in that drawings, and connect the buttons to the inherited buttonThing property via an outlet. But wait, the buttonThing property was announced in the superclass and doesn't even appear in the code of the subclasses. So how do I connect the buttons to that outlet?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
1.2k views
Welcome To Ask or Share your Answers For Others

1 Answer

You can ctrl-drag the UIButton from your storyboard to your BasicController for each subclass you have laid out in your storyboard. You can then use the buttonThing in each subclass as usual.

Remember to link your subviewcontrollers to their respective viewcontrollers in the storyboard.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...