ビューを持つ別のクラスを作成し、そのクラスを画面上で呼び出したいと考えています。アプリを実行すると、ビューが表示されません。その構造を削除してメイン ファイルにボタンを作成すると、正常に動作します。別のクラスに置くと機能しません。
MyView.h
#import <UIKit/UIKit.h>
@interface viewHome : UIViewController
-(UIView*) myHome;
@end
MyView.m (テスト用ボタンの作成)
#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];
}
ありがとう