在表视图中不显示数据

编程入门 行业动态 更新时间:2024-10-28 00:18:13
本文介绍了在表视图中不显示数据 - 当没有数据从api返回时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有15个集合视图单元格。当用户点击每个单元格时,相应的单元格数据将显示在下一个屏幕表格视图中。但是,某些单元格没有任何数据。在这种情况下我需要在表格中查看没有数据。如何显示??

I have some 15 collection view cell.when user click each cell, that respective cell data will display in next screen table view.But , some cell are don't have any data.In that case i need to shoe in table view that "No Data".How to show that??

这是我的代码:

这些是我的表视图中的委托方法:

These are the delegate method in my table view :

// array to store the value from json var arrDict = [Businessdata]() func numberOfSectionsInTableView(tableView: UITableView) -> Int { return 1 } // number of rows func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return self.arrDict.count } // calling each cell based on tap and users ( premium / non premium ) func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { //let cell:customCell = self.TableViewList.dequeueReusableCellWithIdentifier("cell") as! customCell let cell:customCell = tableView.dequeueReusableCellWithIdentifier("cell") as! customCell cell.vendorName.text = arrDict[indexPath.row].BusinessName cell.vendorAddress.text = arrDict[indexPath.row].Address cell.VendorRating.rating = arrDict[indexPath.row].Rating! return cell }

请帮帮我,哪里我必须申报。我是ios开发的新手。谢谢!

Please help me out, where i have to declare that .I am new to ios development.Thanks !

推荐答案

试试这个:

func numberOfSectionsInTableView(tableView: UITableView) -> Int { var numOfSection: NSInteger = 0 if YourArraydata.count > 0 { self.tableView.backgroundView = nil numOfSection = 1 } else { var noDataLabel: UILabel = UILabel(frame: CGRectMake(0, 0, self.tableView.bounds.size.width, self.tableView.bounds.size.height)) noDataLabel.text = "No Data Available" noDataLabel.textColor = UIColor(red: 22.0/255.0, green: 106.0/255.0, blue: 176.0/255.0, alpha: 1.0) noDataLabel.textAlignment = NSTextAlignment.Center self.tableView.backgroundView = noDataLabel } return numOfSection }

更多推荐

在表视图中不显示数据

本文发布于:2023-10-30 22:17:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1544160.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:视图   中不   数据

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!