簡體   English   中英

shouldAutorotateToInterfaceOrientation但沒有任何反應

[英]shouldAutorotateToInterfaceOrientation but nothing happens

我們的應用程序被拒絕,因為應用程序不會顛倒旋轉。

所以我們有一個tabbar App,將此代碼添加到所有標簽...

shouldAutorotateToInterfaceOrientation

沒有意義,將此代碼添加到Appdelegate沒有幫助,我們做錯了什么?

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

UITabbarcontroller是UIViewcontroller的子類。 要解決您的問題,只需為您創建子類或為您添加類別UITabbarcontroller實現:

@interface UITabBarController (rotation)
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation;
@end

@implementation UITabBarController (rotation)
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
     return YES;
}
@end

如果您想使標簽欄僅旋轉為縱向和顛倒,請使用以下代碼

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

確保每個 UIViewController實現

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

暫無
暫無

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

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