因此,正如標題所說,我在iPad上有一個hdmi和註冊用於屏幕連接的觀察者,一旦連接,用戶選擇res並輸出一個視圖。但是,如果我從筆尖或甚至從程序視圖控制器加載視圖,則ipad將以縱向顯示橫向視圖(是的,兩種情況均設置爲橫向)。IOS - 外部(HDMI)輸出只填充屏幕的一半,除非手動編碼視圖
I.e.
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];
它運行像某種形式的神奇夢想:
但是我希望視圖 - 控制加載(而努力!)所以,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];
}
按照要求,這是我如何加載視圖 - 控制與外部屏幕的大小初始化。謝謝
「縱向景觀視圖」被截斷或旋轉了嗎?我的意思是,如果您在第二個示例中添加了標籤,它會顯示在屏幕左上角還是左下角呈90度? – jrturton
對不起,應該說明一下。當您在屏幕的一半中看到視圖時,它是風景但旋轉。所以,如果我添加一個標籤,那麼它會顯示它隨着從下到上的文本旋轉。 –
你可以包含來自'nibless'視圖控制器的'loadView'方法的代碼,展示如何創建視圖,從哪裏獲取外部顯示的尺寸等? – jrturton