久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

UINavigationController 和 UITabBarController 中的選擇性自

Selective Autorotation within a UINavigationController and UITabBarController(UINavigationController 和 UITabBarController 中的選擇性自動旋轉)
本文介紹了UINavigationController 和 UITabBarController 中的選擇性自動旋轉的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

您好!這是場景.

從導航控制器開始(并且不存在標簽欄 - 它從先前的視圖控制器推送中隱藏),我初始化一個新的視圖控制器并將其推送到導航控制器堆棧上.這個新的 VC 包含一個孤獨的 UIView,我以編程方式在其中添加一個具有相同框架的 UIScrollView.(我想避免使用 UIView,但這是我可以將 self.view 分配給某些東西的唯一方法.我懷疑投射 UIScrollViewUIView 中的 viewDidLoad 是不可取的.)

Starting with a navigation controller (and no tab bar is present - it is hidden from a previous view controller push), I init a new view controller and push it onto the nav controller stack. This new VC contains a lonesome UIView into which I programmatically add a UIScrollView with the same frame. (I wanted to avoid the UIView, but this was the only way I could get self.view to be assigned to something. I suspect casting a UIScrollView to UIView in viewDidLoad is not advisable.)

所以現在我們有了一個導航欄和一個滾動視圖.我已經將它設置為滾動瀏覽一些圖像(我知道,這讓我大吃一驚!),效果很好.現在我希望它支持自動旋轉.所以我在 VC 中這樣回應:

So now we have a nav bar, and a scroll view. I've set it up to scroll through some images (big surprise, I know!), and that works just fine. Now I want this to support autorotation. So I respond in the VC like so:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}

編譯并運行.啊……什么都沒有.顯然我做錯了什么.

Compile and run. Aaaand ... nothing. Obviously I've done something wrong.

現在,我已經閱讀了有關 UINavigationController 和 autorotation 的帖子,我知道了懷疑我用錯了方法,讓它變得比必要的復雜.

Now, I've already read the post regarding UINavigationController and autorotation, and I get the sneaking suspicion that I'm going about this the wrong way, and making it way more complicated than necessary.

必須有更好的方法來呈現支持自動旋轉的 UIScrollView.也許導航控制器擋住了路,但我不知道如何繞過它.

There's got to be a better way to present a UIScrollView that supports autorotation. Perhaps the Nav Controller is getting in the way, but I'm not sure how to get around it.

理想情況下,我想要不顯示任何導航欄的東西.相反,我們有一個從頂部顯示/隱藏的工具欄/狀態欄(就像您在播放視頻時看到的那樣).如果導航欄必須保留 - 或者如果這真的是我在播放視頻與工具欄時看到的較短高度的導航欄,但是我可以旋轉嗎?問題是,我只希望它在查看像素時以這種特定模式旋轉.其他時間都沒有.

Ideally, I'd like something without any kind of nav bar showing. Instead, we have a toolbar/status bar that appears/hides from the top (like you see when playing video). If the nav bar must remain - or if that's REALLY a shorter-height nav bar I'm seeing when playing video vs. a toolbar, however do I get the thing to rotate around? The thing is, I only want it to rotate in this particular mode, when viewing the pix. Not at any other time.

我敢嘗試使用模態VC嗎?(Yeccch - 不,這也不對.而且它還有一個導航欄.)

Dare I try using a modal VC? (Yeccch - no, that can't be right either. Plus it has a nav bar anyway.)

推薦答案

你可以通過創建一個 UITabBarController 類別來解決這個問題.

You can solve this without subclassing by creating a UITabBarController category.

這是處理我的情況的類別實現,其中我有與我的選項卡關聯的匿名 UINavigationControllers 和自定義 UIViewController 子類作為 UINavigationControllers 的根視圖控制器:

Here is the category implementation which handles my case where I have anonymous UINavigationControllers associated with my tabs and custom UIViewController subclasses as the root view controllers of the UINavigationControllers:

@implementation UITabBarController (Rotation)

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{   
    if ([self.selectedViewController isKindOfClass:[UINavigationController class]]) {
        UIViewController *rootController = [((UINavigationController *)self.selectedViewController).viewControllers objectAtIndex:0];
        return [rootController shouldAutorotateToInterfaceOrientation:interfaceOrientation];
    }
    return [self.selectedViewController shouldAutorotateToInterfaceOrientation:interfaceOrientation];
}

@end

我在 UINavigationController 上還有一個類別,默認返回 YES.因此,默認行為是啟用旋轉,我可以從 shouldAutorotateToInterfaceOrientation:interfaceOrientation 返回 NO,只針對我希望禁用旋轉的控制器和方向.

I also have a category on UINavigationController which defaults to returning YES. So, the default behavior is to enable rotation and I can return NO from shouldAutorotateToInterfaceOrientation:interfaceOrientation for just the controllers and orientations for which I wish to disable rotation.

這篇關于UINavigationController 和 UITabBarController 中的選擇性自動旋轉的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Clean autorotation transitions in a paging UIScrollView(清除分頁 UIScrollView 中的自動旋轉轉換)
How to create an image from a UIView / UIScrollView(如何從 UIView/UIScrollView 創建圖像)
How to auto scroll UIScrollView using timer?(如何使用計時器自動滾動 UIScrollView?)
Programmatically force a UIScrollView to stop scrolling, for sharing a table view with multiple data sources(以編程方式強制 UIScrollView 停止滾動,以便與多個數據源共享表格視圖) - IT屋-程序員軟件開發技術分享
What does contentOffset do in a UIScrollView?(UIScrollView 中的 contentOffset 有什么作用?)
How to implement UIScrollView with 1000+ subviews?(如何實現具有 1000 多個子視圖的 UIScrollView?)
主站蜘蛛池模板: 亚洲国产中文字幕 | 亚洲a视频 | 日韩一区精品 | 一级高清免费毛片 | www国产精 | 99在线免费视频 | 91亚洲国产| 夜夜骑天天干 | 中文字幕日韩欧美一区二区三区 | 亚洲黄色网址视频 | 国产高清精品一区二区三区 | 人人看人人干 | 在线免费看黄 | 中文字幕动漫成人 | 午夜爱爱毛片xxxx视频免费看 | 久久91精品| 日韩二区三区 | 日韩欧美亚洲一区 | 欧美专区日韩专区 | 中国美女av | 亚洲日韩中文字幕一区 | 国产免费黄网 | 成人免费三级电影 | 国产一区二区在线免费观看 | 久久精品国产一区二区三区不卡 | 精品一二区 | 性一爱一乱一交一视频 | 99这里只有精品视频 | 人人澡人人射 | 国产精品呻吟久久av凹凸 | 北条麻妃一区二区三区在线视频 | 免费成人毛片 | 亚洲视频在线看 | 久久精品国产一区二区电影 | 午夜精品在线观看 | 国产专区在线 | 久久久久成人精品 | 日韩视频免费看 | 亚洲精品乱 | 国产性生活一级片 | 91九色porny首页最多播放 |