iOS   发布时间:2022-03-30  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ios – 顶行在reloadData()上从UITableView消失,直到向上/向下滚动大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_197_1@
我正在iOS应用程序中将Web服务中的项目加载到UITableView.
这里的问题是,只要加载数据,顶部可见而没有滚动的行数就会变得不可见.该页面空白.
如果我向下滚动,下面的图像将完美加载.再次向上滚动顶部图像也可以正确加载.

详细截图链接https://www.dropbox.com/sh/nfxcgw2ple8g4mt/AAAOTswWDEN-s2-dAbJ1bHu7a?dl=0

class FirstViewController: UIViewController,UITableViewDatasource,UITableViewDelegate{

   override func viewDidLoad() {
        super.viewDidLoad()[1]

//        self.client = xxxxxxxxxxxx;

//
//   fetching from server logic query
//
//             
    query.readWithCompletion({ (result,error) -> Void in

            if (error == nil)
            {
                self.activityInDicatorView.hidden = true // loading inDicator 
                self.allResults = result.items
                    println( self.allResults!.count )
                self.tableView.hidden = false
                self.tableView.reloadData()
            }
            else{
                println(error.localizedDescription) // error
            }

        })

    }

   func tableView(tableView: UITableView,numberOfRowsInSection section: int) -> Int
    {
        if (allResults != nil) {  return self.allResults.count }
        else {  return 0 }
    }

    func tableView(tableView: UITableView,heightForRowATindexPath indexPath: NSIndexPath) -> CGFloat 
    { return 200 }

    func tableView(tableView: UITableView,cellForRowATindexPath indexPath: NSIndexPath) -> UITableViewCell
    {
         var cell: CellClass  = self.tableView.dequeueReusableCellWithIdentifier("item") as! CellClass

        return cell //typo

}

解决方法

尝试;

func tableView(tableView: UITableView!,cellForRowATindexPath indexPath: NSIndexPath!) -> UITableViewCell {
    let cell:CellClass   = tableView.dequeueReusableCellWithIdentifier("item",forIndexPath: indexPath) as! CellClass

    return cell
}

别忘了注册你的手机.

大佬总结

以上是大佬教程为你收集整理的ios – 顶行在reloadData()上从UITableView消失,直到向上/向下滚动全部内容,希望文章能够帮你解决ios – 顶行在reloadData()上从UITableView消失,直到向上/向下滚动所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。