小编Ban*_*sal的帖子

如何禁用tableView滚动?

当我在viewController中默认添加tableView时,tableView会滚动,但我希望它是静态的.可能吗?

这是我的代码:

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

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell
{
    let cell = tableview.dequeueReusableCellWithIdentifier("cell") as! TableViewCell
    cell.username.text = names[indexPath.row]
    return cell
}

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

func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat
{
    return 50.0
}
Run Code Online (Sandbox Code Playgroud)

ios swift

3
推荐指数
3
解决办法
5337
查看次数

标签 统计

ios ×1

swift ×1