Ios 信号Sigabrt错误,部分中的表格视图行
我尝试创建一个包含3个不同部分的静态TableView,每个部分都有另外数量的行:Ios 信号Sigabrt错误,部分中的表格视图行,ios,swift,uitableview,Ios,Swift,Uitableview,我尝试创建一个包含3个不同部分的静态TableView,每个部分都有另外数量的行: let numberOfRowsAtSection:[Int] = [5,4,3] 这是我的numberOfRowsinSection函数: override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { var rows: Int = 0 if sectio
let numberOfRowsAtSection:[Int] = [5,4,3]
这是我的numberOfRowsinSection函数:
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
var rows: Int = 0
if section < numberOfRowsAtSection.count {
rows = numberOfRowsAtSection[section]
}
return rows
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath)
return cell
}
override func tableView(tableView:UITableView,numberofrowsinssection:Int)->Int{
变量行:Int=0
如果节UITableView单元格{
让cell=tableView.dequeueReusableCellWithIdentifier(“cell”,forIndexPath:indexPath)
返回单元
}
但每次我尝试执行这个,我都会出错
信号信号机
由于未捕获异常“NSRangeException”而终止应用程序,原因:“***-[\uu NSArray0 objectAtIndex:]:索引0超出空NSArray的界限”
如果我用
返回0
替换返回行
,则错误已修复。有人知道我做错了什么以及如何修复吗?请添加numberOfSections实现,以及cellForRow实现Post您的cellForRowAt
函数。另外,发布您所遇到错误的完整描述。实际上,如果您使用的是静态表视图,您根本不需要动态委托和数据源方法,因为所有单元格都可以通过出口和操作访问。我添加了mag_zbcw,这行代码正是导致错误的原因?请添加numberOfSections实现,还有cellForRow实现post您的cellForRowAt
函数。另外,请发布您遇到的错误的完整描述。实际上,如果您使用的是静态表视图,您根本不需要动态委托和数据源方法,因为所有单元格都可以通过出口和操作访问。我添加了mag_zbcw,这是哪一行代码导致的错误?