簡體   English   中英

從橫向視圖 controller 推送縱向視圖 controller

[英]Push a view controller in portrait from a view controller that's in landscape

我有一個 UITableViewController 可以在縱向和橫向上工作。 從這個 controller 我將另一個視圖 controller 推到導航 controller。 這個新的 viewController 只是縱向的。

問題是,當我處於橫向並推動視圖 controller 時,新的視圖控制器也處於橫向狀態,直到我將其旋轉為縱向。 然后它被卡在肖像中,因為它應該是。

是否有可能總是讓它出現在肖像中? 即使它的父母在橫向推動它?

更新:

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

在 viewWillAppear: 狀態欄方向改變后放這個:

//present/dismiss viewcontroller in order to activate rotating.
UIViewController *mVC = [[[UIViewController alloc] init] autorelease];
[self presentModalViewController:mVC animated:NO];
[self dismissModalViewControllerAnimated:NO];

希望它會有所幫助!

PS在 sdk 3.2.5 ios 5.0.1 上測試。

在您viewWillAppear:使用以下代碼:

[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];

暫無
暫無

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

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