I have a base view controller BaseUIViewController
which is extended from UIViewController
. I have two UIButtons
at the bottom of this ViewController. Basically I want these two buttons on every UIViewController
at the same place through out my app. When I extend BaseUIViewController
, I don't see them in the children view controllers.
I have given IBOutlets to the buttons too!
I am new to programming. Please help. Isn't this way inheritance work?
Asked
Active
Viewed 62 times
0

StackOverFlow UserID
- 43
- 6
3 Answers
1
You can create a UIViewControllerContainment. This Stackoverflow's post explains it in detail how you can create it and make it work. Similalry, also have a look at this Stackoverflow's post. Here it is done using childViewControllers.
0
Make sure you put these button properties in @interface
instead of @implement
, only properties in @interface
can see in subclasses. Here is example:
@interface BaseUIViewController
@property (nonatomic, weak) IBOutlet UIButton *button1;
@property (nonatomic, weak) IBOutlet UIButton *button2;
@end

ninjapro
- 105
- 5
0
Both the ways which MUNAHIL answered above, are the best ones I believe. In case you want to achieve this in a more basic way, you can do as below.
- Add the two
UIButton
s in theBaseUIViewController
(either programmatically in viewDidLoad or in storyboard). In case you need, you may like to add a UIToolBar first and then the buttons on top of it. Make other view controllers a subclass of
BaseUIViewController
.@interface SomeViewController: BaseUIViewController
Now, all your view controllers will have the two buttons by default.

Rashmi Ranjan mallick
- 6,390
- 8
- 42
- 59