Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xcode 由于大小原因,TableView未加载完整数组_Xcode_Uitableview_Swift2 - Fatal编程技术网

Xcode 由于大小原因,TableView未加载完整数组

Xcode 由于大小原因,TableView未加载完整数组,xcode,uitableview,swift2,Xcode,Uitableview,Swift2,我有一个数组,输入了22个。表格视图的每个单元格的高度为80。我检查了整个tableview的大小是600*600。所以我只能加载600/80=7个单元 所以我希望将数组的全部内容加载到表视图中,这样用户就可以向下滚动内容了。 当我在模拟器中加载表格视图时,我只能看到7个单元格。滚动已锁定,我无法访问更多记录 请建议我如何做到这一点??我希望这次我能解释得更好 class RestaurentTableViewController: UITableViewController { var re

我有一个数组,输入了22个。表格视图的每个单元格的高度为80。我检查了整个tableview的大小是600*600。所以我只能加载600/80=7个单元

所以我希望将数组的全部内容加载到表视图中,这样用户就可以向下滚动内容了。 当我在模拟器中加载表格视图时,我只能看到7个单元格。滚动已锁定,我无法访问更多记录

请建议我如何做到这一点??我希望这次我能解释得更好

class RestaurentTableViewController: UITableViewController {

var restaurantNames = ["A", "B", "C", "D", "E", "F", "G", "H",
"I", "J", "K", "L", "M",
    "N", "O", "P", "Q", "R",
    "S", "T", "U"] override func viewDidLoad() {
    super.viewDidLoad()
    //self.tableHeightConstraint.constant = CGFloat(restaurantNames.count * 80)

}

override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
    return 1
}

override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {

    return restaurantNames.count
}


override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as! RestaurantTableViewCell


cell.nameLabel.text = restaurantNames[indexPath.row]
cell.thumbnailImageView.image = UIImage(named: restaurantImages[indexPath.row])
        cell.locationLabel.text = restaurantLocations[indexPath.row]
        cell.typeLabel.text = restaurantTypes[indexPath.row]

    return cell
}

}这个问题让我有点困惑。你所要求的会自动发生。请参阅UITableView的文档,以及UITableViewDelegate和UITableViewDataSource中的各种委托方法


你有什么理由相信滚动不起作用吗

请详细说明您尝试了什么,并发布您的代码。@Ashish我不知道您在问什么;它要么看起来像是一个关于隐藏代码的问题,要么是关于您对单元可重用性的混淆的问题,或者可能是代码中显示意外行为的一个小错误。不管怎样,你能给我们看一下所有相关的代码吗?viewcontroller中的tableview方法将是一个良好的开端,以及如何填充数据数组。你可以把我(@Zil)挂上旗子,一旦你穿上了,我就过来看看again@Zil我还保留了密码。我是新来的如何标记一个我不认识的人这一切乍一看都很好。你的问题是你不能滚动查看新内容,对吗?或者您可以滚动但单元格为空?您确定在模拟器中滚动正确吗?您必须单击滚动-常规滚动不起作用。这就像我的数组有var restaurantNames=[“A”、“B”、“C”、“D”、“E”、“F”、“G”、“H”、“I”、“J”、“K”、“L”、“M”、“N”、“O”、“P”、“Q”、“R”、“S”、“t”、“U”]一样。当我加载应用程序时,它会将表加载到H。我希望加载所有数据。我的手机高度是80。所以它装载7个完整的和第8个半部分。让我知道,如果我仍然没有意义,我会尝试分享我的代码。