因此,正如标题所说,我在iPad上有一个hdmi,并且注册了屏幕连接的观察者,在连接时用户选择res并输出视图.
但是,如果我从笔尖加载视图,或者甚至从编程视图控制器加载视图,ipad会以纵向显示横向视图(是的,两种情况都设置为横向).
即
ExternalViewController *ex = [[ExternalViewController alloc] init];
[externalWindow setRootViewController:ex];
Run Code Online (Sandbox Code Playgroud)
做这个:
如果我以编程方式创建视图.像这样:
UIView *test = [[UIView alloc] initWithFrame:[externalScreen applicationFrame]];
[test setBackgroundColor:[UIColor whiteColor]];
UILabel *msgLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 40, 100, 30)];
msgLabel.text = @"External!";
[test addSubview:msgLabel];
Run Code Online (Sandbox Code Playgroud)
它像某种形式的神奇梦想一样运行:
但是我希望viewcontroller加载(并且工作!)所以,StackOverflow,我问你.以前有人遇到过这个吗?
编辑:不言而喻,常见的敏感答案不会得到赏金,我是在修复后,而不是解决方法.由于我有限的大脑,我所能想到的就是创建一个基于它的输入创建视图的方法,并将其作为外部监视器的子视图添加,很明显这是一个黑客解决方案,所以修复得到赞赏!谢谢!
编辑:
-(id)initWithFrame:(CGRect)_rect
{
rect = _rect;
if (self = [super init])
{
externalView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"105.png"]];
externalView.alpha = 0.0;
[externalView setFrame:rect];
[externalView setBackgroundColor:[UIColor yellowColor]];
self.view = [[UIView alloc] initWithFrame:rect];
self.view.backgroundColor = [UIColor whiteColor];
return self;
}
}
- …
Run Code Online (Sandbox Code Playgroud)