我有一个包含视图控制器类的静态库。
在包含静态库(和头文件)之后,如何在 Xcode 中的新项目中调用此视图控制器?
在静态库上查看控制器:
#import "VC.h"
@interface VC ()
@property (nonatomic, strong) UILabel *label;
@property (nonatomic, strong) UIWindow *window;
@end
@implementation VC
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
_window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
_window.backgroundColor = [UIColor whiteColor];
[self.view addSubview: _window];
[super viewDidLoad];
self.label = [[UILabel alloc] initWithFrame:CGRectMake(115.0f, 150.0f, 200.0f, 30.0f)];
self.label.text = @"hello world!";
[self.view addSubview:self.label];
// Do any additional setup after loading the view.
}
@end
我试图在一个新项目中分配这个 ViewController 并调用它......但不工作:
VC *vc = [[VC alloc] init];
[self presentViewController:vc animated:YES completion:nil];
我还缺少其他东西吗?
*更新
在最后一次编辑之后,现在我可以看到视图控制器,但它不在主视图控制器的顶部,加载后它变成黑色......有什么想法吗?