大佬教程收集整理的这篇文章主要介绍了IOS – 外部(hdmi)输出只填充屏幕的一半,除非手动编码视图,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
但是,如果我从一个笔尖加载视图,或者甚至从一个程序视图控制器,ipad显示纵向视图(是的,两种情况都设置为横向)。
也就是说
ExternalViewController *ex = [[ExternalViewController alloc] init]; [externalWindow setRootViewController:ex];
做这个:
如果我创建视图本身程序。像这样:
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];
它运行像某种形式的神奇梦想:
但我想要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; } } - (void)loadView { self.view = [[UIView alloc] initWithFrame:rect]; self.view.BACkgroundColor = [UIColor blackColor]; [self.view addSubview:externalView]; }
根据要求,这是我如何加载viewcontroller,初始化外部屏幕的大小。谢谢
// ugly,don't use this in real code if ([UIScreen screens].count == 1) return; // just one screen,eww. // getTing the secondary screen UIScreen *screen = [[UIScreen screens] objectATindex:1]; __block UIScreenMode *highestWidthMode = NULL; [screen.availableModes enumerateObjectsUsingBlock:^(id obj,NSUInteger idx,BOOL *stop) { UIScreenMode *currentModeInLoop = obj; if (!highestWidthMode || currentModeInLoop.size.width > highestWidthMode.size.width) highestWidthMode = currentModeInLoop; }]; // setTing to the highest resolution available screen.currentMode = highestWidthMode; NSLog(@"screen.currentMode = %@",screen.currentModE); screen.overscanCompensation = UIScreenOverscanCompensationScale; // initializing screen secondWindow = [[UIWindow alloc] initWithFrame:[screen bounds]]; [secondWindow setScreen:screen]; // other view is a UIViewController,just remember to return NO in - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation or the iOS will rotate the frame. UIViewController *vc = [[OtherView alloc] initWithNibName:@"OtherView" bundle:nil]; secondWindow.rootViewController = vc; [secondWindow makeKeyAndVisible];
以上是大佬教程为你收集整理的IOS – 外部(hdmi)输出只填充屏幕的一半,除非手动编码视图全部内容,希望文章能够帮你解决IOS – 外部(hdmi)输出只填充屏幕的一半,除非手动编码视图所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。