簡體   English   中英

NavigationBar在TabBarViewController中隱藏TableView

[英]NavigationBar hides TableView in TabBarViewController

我有一個ViewController推TabBarViewController。 在該TabBar View Controller中,我有4個選項卡。 這些選項卡欄中的兩個是UITableViewControllers,另外兩個是ViewController。 第一個選項卡是一個表視圖控制器,並且工作正常,即未被導航欄隱藏。 第三個選項卡是另一個TableViewController,被導航欄部分覆蓋。 第一部分和第一個單元格隱藏在導航欄下方。 過去有人遇到過這個問題嗎?有人知道解決方案嗎? 我已經嘗試了一些方法,例如手動調整幀大小

self.tableView.frame = CGRectMake(10,10,self.view.bounds.size.width -20, self.view.bounds.size.height-20);

那似乎沒有用。 我也嘗試過AutoLayout,但沒有用。 我不知道該怎么辦 任何人都對如何解決此問題有任何建議或想法。

編輯:我已經嘗試了edgesForExtendedLayout但它使我的導航edgesForExtendedLayout更深。 它可以對導航欄中的顏色變化進行動畫處理,就像加載欄一樣。

注意:這僅在ios7中發生。 我只是在iOS 6.1中對其進行了模擬,並且導航欄根本沒有涵蓋表格視圖控制器,這對我來說很奇怪。 有人有什么建議嗎?

編輯#2:注意到這是iOS 7>問題,我做了以下操作,但現在導航欄的顏色已更改為較暗的顏色。

if([[[[UIDevice currentDevice] systemVersion] componentsSeparatedByString:@"."][0] intValue] >= 7)
    {
        if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
        {
            self.edgesForExtendedLayout = UIRectEdgeNone;
            self.extendedLayoutIncludesOpaqueBars = YES;
            self.automaticallyAdjustsScrollViewInsets = NO;
        }
    }

在UITableViewController的viewDidLoad方法中(假定它已加載對tabBarController的調用),該方法與選項卡相關聯

if ([self respondsToSelector:@selector(edgesForExtendedLayout)]) {
    self.edgesForExtendedLayout = UIRectEdgeNone;
    self.tableView.contentInset = UIEdgeInsetsMake(0., 0., CGRectGetHeight(self.tabBarController.tabBar.frame), 0);
}

我用以下方法修復了該問題:

if ([self respondsToSelector:@selector(edgesForExtendedLayout)]) {
    viewcontroller.edgesForExtendedLayout = UIRectEdgeNone;
    viewcontroller.extendedLayoutIncludesOpaqueBars = NO;
    viewcontroller.automaticallyAdjustsScrollViewInsets = NO;
}

暫無
暫無

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

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