簡體   English   中英

以橫向顯示視圖

[英]Display view in Landscape orientation

我正在顯示視頻,我需要旋轉視圖,以便以橫向顯示。 我寫了下面的代碼,正是它正是我想要的。 問題是,當我單擊“后退”按鈕時,(顯示承運人標題和時間的欄)保持為“橫向”(對於假定為縱向的視圖)。 我該如何糾正?

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}

現在,只需在您的相框中放置新位置即可,即:

-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration{
    if(self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
       self.interfaceOrientation == UIInterfaceOrientationLandscapeRight){
        video1.frame = CGRectMake(50, 650, 150, 30);
        video2.frame = CGRectMake(350, 650, 150, 30);
    } else {
        video1.frame = CGRectMake(10, 10, 150, 30);
        video2.frame = CGRectMake(610, 10, 150, 30);
    }
}

並保持原樣

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return YES;
}

可以在您要更改的方法中調用方向。 這樣知道..

例:

-(void)videoDisplayMothod {
    //video code
    toInterfaceOrientation = UIInterfaceOrientationLandscapeLeft;
}

您是否定義了:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

對於其視圖應為縱向的控制器? (您在關閉視頻后返回的那個)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM