Ios 未显示表格视图中的单元格
我在一个视图控制器中使用UITableView,并使用名为ListCell的自定义类。将显示表格视图和单元格,但不显示单元格中的内容,因此单元格为空。但如果我按下单元格,它就会执行它的任务。因此,内容在那里,但没有显示出来。我认为这与我如何将类注册到自定义类型ListCell有关。下面是我在viewDidLoad中声明它的方式Ios 未显示表格视图中的单元格,ios,xcode,uitableview,Ios,Xcode,Uitableview,我在一个视图控制器中使用UITableView,并使用名为ListCell的自定义类。将显示表格视图和单元格,但不显示单元格中的内容,因此单元格为空。但如果我按下单元格,它就会执行它的任务。因此,内容在那里,但没有显示出来。我认为这与我如何将类注册到自定义类型ListCell有关。下面是我在viewDidLoad中声明它的方式 self.tblListView.registerClass(ListCell.self, forCellReuseIdentifier: "Cell") 上面这行有什
self.tblListView.registerClass(ListCell.self, forCellReuseIdentifier: "Cell")
上面这行有什么问题吗。是什么导致单元格内容不显示
我还尝试启用大小类,但没有成功。此外,所有单元格都是以编程方式创建的
下面的代码行负责显示单元格数据
cell.displayAlertData(mutArrAlertList.objectAtIndex(indexPath.row) as! [NSObject : AnyObject])
问题是第一个索引处的MutarAllertList对象是可选类型(可选温度)。我认为如果这不是可选的,那么这是唯一可行的方法。正在向对象传递推送通知,推送通知发送的内容不是可选的。所以在某个地方它会随机变成可选类型。有没有办法摆脱它周围的可选值
以下是行方法的单元格:
func tableView (tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cellIdentifier: String = "Cell"
var cell = tableView.dequeueReusableCellWithIdentifier("Cell") as! ListCell
//if cell == nil
//{
//let nib: NSArray = NSBundle.mainBundle().loadNibNamed("ListCell", owner: self, options: nil)
//cell = (nib.objectAtIndex(0) as? ListCell)!
//}
cell.selectionStyle = UITableViewCellSelectionStyle.None
print("")
print("This is cell: \(mutArrAlertList.objectAtIndex(indexPath.row) as! [NSObject : AnyObject])") //did this to check what the value is and it is an optional
cell.displayAlertData(mutArrAlertList.objectAtIndex(indexPath.row) as! [NSObject : AnyObject])
if indexPath.row == mutArrAlertList.count-1
{
if ApplicationDelegate.intPage > mutArrAlertList.count
{
//do nothing
}
else
{
ApplicationDelegate.intPage = ApplicationDelegate.intPage + 10
self.reloadDataFromdb()
}
}
return cell
}
你在使用序列图像板吗?我在序列图像板中创建了UITableView,但没有创建单元格。如果你尝试使用表格视图单元格,我将编辑我的问题并发布我认为错误的内容Show me CellForRow方法,我将解决你的问题@哈希尔·乔希