簡體   English   中英

UITabBar將隱藏UITableView的最后一個單元格

[英]UITabBar will hide the last cell of the UITableView

self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, [UIScreen mainScreen].bounds.size.height ) style:UITableViewStylePlain];

在此輸入圖像描述

如果我將tableview框架更改為

(0.0, 0.0, 320.0, [UIScreen mainScreen].bounds.size.height -49.0)

在此輸入圖像描述

滾動條會留下空白,我不喜歡它。我怎么能解決這個問題?

非常感謝你。

您可以嘗試設置該表視圖的contentInset 在iOS 7中有一個topLayoutGuidebottomLayoutGuide (這就是你想要的)。 UITabBarController里面, bottomLayoutGuide應該基本上給你底部欄的高度。

tableView.contentInset = UIEdgeInsetsMake(0, 0, self.bottomLayoutGuide.length, 0);

應該做的伎倆。

將半透明屬性設置為NO

// In init or viewDidLoad of tab bar controller
self.tabBar.translucent = NO;

現在標簽欄應該調整表格視圖的大小。

translucent屬性適用於iOS 7及更高版本。

//在viewDidLoad()中,以下行為我工作

self.edgesForExtendedLayout = UIRectEdge.None self.navigationController?.navigationBar.translucent = false self.tabBarController?.tabBar.translucent = false

你有2個選擇:

第一

self.tableView.contentInset.bottom = self.tabBarController?.tabBar.frame.height ?? 0

這樣做可以保存tab欄的透明屬性。


第二在設計視圖中,只需取消選中Under Bottom Bars的選項,但是請記住, tab bar看起來像純色(背后沒有東西)。

在此輸入圖像描述

在此輸入圖像描述

斯威夫特

self.tabBar.isTranslucent = false

注意:@Eric Amorde答案轉換為Swift。

暫無
暫無

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

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