I want to create a different class with a view and call that class on screen. When I run the app, the view does not appear. If I delete that structure and create the button on the main file, it works fine. When I put it on a different class, it does not work.
MyView.h
#import <UIKit/UIKit.h>
@interface viewHome : UIViewController
-(UIView*) myHome;
@end
MyView.m (Creating a button for test)
#import "viewHome.h"
@implementation viewHome
-(UIView*) myHome {
UIView * myScreen = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
myScreen.backgroundColor = [UIColor whiteColor];
UIButton * myButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
myButton.frame = CGRectMake(100,100,100,44);
[myButton setTitle:@"Login" forState:UIControlStateNormal];
[myScreen addSubview:myButton];
return myScreen;
}
@end
viewController.m [...]
- (void)viewDidLoad
{
[super viewDidLoad];
viewHome * fncScreen;
UIView * homeScreen = [fncScreen myHome];
[self.view addSubview:homeScreen];
}
Thanks