Swift3 为什么我的tableview中的单元格要调整大小
我有一个有两个单元格的tableview。由于某种原因,当我在模拟器中打开时,单元格的大小会调整。试图理解为什么。我添加了视图的图像 这是视图代码。现在,我只希望单元格能在我在IB中设置的高度上创建Swift3 为什么我的tableview中的单元格要调整大小,swift3,xcode8,Swift3,Xcode8,我有一个有两个单元格的tableview。由于某种原因,当我在模拟器中打开时,单元格的大小会调整。试图理解为什么。我添加了视图的图像 这是视图代码。现在,我只希望单元格能在我在IB中设置的高度上创建 import UIKit class userMenuViewController: BaseViewController,UITableViewDataSource,UITableViewDelegate { var surveyNameArr = ["aaa","bbb","ccc"]
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.
}
*/
}
这就是我要找的:
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat
{
return 100.0;//Choose your custom row height
}
提供更多细节。就像任何人都可以通过看你的截图来判断一样。告诉我你在情节提要和代码中做了什么,这样我就可以告诉你你做错了什么。