2017-10-20 60 views
0

我有UITableViewController作爲UINavigationController的根。它總是以一種奇怪的白色長條出現在頂部UITableViewController在頂部有一個奇怪的白色條紋(包含圖片)

enter image description here

(說白了帶始終在狀態欄的高度的高度)。如果我將tableView的背景顏色更改爲紅色,則strip變紅,所以這意味着問題出在UITableViewController

我認爲這可能是問題所在,因爲表視圖標題或節標題,所以我將此代碼添加到檢查

override func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat { 
     return 10 
    } 

    override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? { 
     let view = UIView() 
     view.backgroundColor = UIColor.green 
     return view 
    } 

    func configureTabeView() { 
//  self.tableView.contentInset = UIEdgeInsets(top: -1, left: 0, bottom: 0, right: 0) 
     let viewHeader = UIView(frame: CGRect(x: 0, y: 0, width: 0, height: 1)) 
     viewHeader.backgroundColor = UIColor.red 
     self.tableView.tableHeaderView = viewHeader 
     tableView.clipsToBounds = true 
    } 

但在那之後,它看起來像enter image description here

其中紅色帶是表頭,貪婪條是節頭。並且有一個奇怪的白色條紋,滾動指示器與白色條紋高度具有相同的偏移量。

+0

也許你正在使用在故事板tableview中的唯一的事。檢查桌面視圖的自動佈局,如果頂部約束在打勾模式下有佈局邊距? –

+0

從滾動指標你可以知道問題是不是在tableview裏面,也許檢查tableview約束或者狀態欄的東西。 –

+0

請參閱:https://stackoverflow.com/questions/38810005/view-doesnt-go-under-status-bar-and-status-bar-is-black – Mars

回答

0

,幫助我在故事板內容插圖設置爲從不enter image description here