2017-05-29 77 views
-2

我有一個tableview與2個單元格。由於某些原因,當我在模擬器中打開時,單元格會調整大小。試圖理解爲什麼。我添加了視圖的圖像。爲什麼我的tableview中的單元格調整大小

這是查看代碼。現在我只想得到我在IB中

import UIKit 

class userMenuViewController: BaseViewController,UITableViewDataSource,UITableViewDelegate { 

var surveyNameArr = ["aaa","bbb","ccc"] 

public func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int 
{ 
    return (surveyNameArr.count) 
} 

public func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell 
{ 

    let cell = tableView.dequeueReusableCell(withIdentifier: "cell2", for: indexPath) as! PrefCell2TableViewCell 



    return (cell) 

} 



public func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath){ 

} 


override func viewDidLoad() { 
    super.viewDidLoad() 

    // Do any additional setup after loading the view. 
    addSlideMenuButton() 
} 

override func didReceiveMemoryWarning() { 
    super.didReceiveMemoryWarning() 
    // Dispose of any resources that can be recreated. 
} 


/* 
// MARK: - Navigation 

// In a storyboard-based application, you will often want to do a little preparation before navigation 
override func prepare(for segue: UIStoryboardSegue, sender: Any?) { 
    // Get the new view controller using segue.destinationViewController. 
    // Pass the selected object to the new view controller. 
} 
*/ 

} 

image of cells in table this is the image of my view

+0

提供更多的細節。就像任何人通過查看你的屏幕截圖一樣。告訴我你在故事板和代碼中做了什麼,這樣我就可以告訴你你做錯了什麼。 –

回答

1

這是設置高度產生的細胞就是我一直在尋找:

func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat 
{ 
    return 100.0;//Choose your custom row height 
} 
相關問題