I have 2 view controllers AViewController and BViewController as an example. I want to add a UI element in the second BViewController from the first AViewController. I thought I would make this happen through the class method but the UIView is not accessable in the BViewController’s class method when called from AViewController.
Implementation of BViewController
+(void)addThatButton{
UIButton *btn = ……
[self.view addSubview:btn]; //<== ERROR
//[BViewController.view addSubview:btn]; //<== ALSO ERROR
}
Implemention of AViewController
[BViewController addThatButton];
Error message I get is “request for member ‘view’ in something not a structure or union”. How to implememnt what I need in the right way or, in other words, how to access BViewController view from the A class?
Thanks
You need to create a function in BViewController
In BViewController.h
In BViewController.m
In AViewController.m