【发布时间】:2016-10-05 22:55:31
【问题描述】:
我的应用中有 1 个类在 AdHoc 部署期间崩溃,但如果通过 Xcode 安装则可以正常工作。我已经从我的设备(iOS 10)符号化了崩溃日志,它们都是一样的:
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 UIKit 0x0000000196507a4c __66-[UISectionRowData refreshWithSection:tableView:tableViewRowData:]_block_invoke + 424
1 UIKit 0x00000001965079f0 __66-[UISectionRowData refreshWithSection:tableView:tableViewRowData:]_block_invoke + 332
2 UIKit 0x00000001964c7368 -[UISectionRowData refreshWithSection:tableView:tableViewRowData:] + 2712
3 UIKit 0x00000001964c67e4 -[UITableViewRowData rectForFooterInSection:heightCanBeGuessed:] + 536
4 UIKit 0x00000001964c6570 -[UITableViewRowData heightForTable] + 60
所以我的想法是,好吧,也许我如何找到我的部分计数存在问题。这是我的课程的代码,非常简单。
class HeaderTableViewController: UITableViewController {
var nonDefaultTitle : String?
var data: [String: [String]] = [:]
var headers : [String] = []
var bodys : [[String]] = []
init(displayData: [String: [String]]) {
super.init(style: .Plain)
data = displayData
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
private override init(nibName nibNameOrNil: String!, bundle nibBundleOrNil: NSBundle!) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
}
override func viewDidLoad() {
super.viewDidLoad()
for key in data.keys {
headers.append(key)
}
for arr in data.values {
bodys.append(arr)
}
tableView.registerNib(UINib(nibName: "DefaultCustomCell", bundle: nil), forCellReuseIdentifier: "DefaultCustomCell")
tableView.estimatedRowHeight = 50
tableView.rowHeight = UITableViewAutomaticDimension
tableView.sectionHeaderHeight = UITableViewAutomaticDimension;
tableView.estimatedSectionHeaderHeight = 100;
let nib = UINib(nibName: "HeaderTableHeaderView", bundle: nil)
tableView.registerNib(nib, forHeaderFooterViewReuseIdentifier: "HeaderTableHeaderView")
if let ttle = nonDefaultTitle {
self.title = ttle
}
else {
self.title = "Talking Tips"
}
}
}
//
// MARK: Helpers
//
extension HeaderTableViewController {
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return headers.count
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return bodys[section].count
}
override func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
let cell = self.tableView.dequeueReusableHeaderFooterViewWithIdentifier("HeaderTableHeaderView")
let header = cell as? HeaderTableHeaderView
header!.titleLabel.text = headers[section]
return cell
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("DefaultCustomCell", forIndexPath: indexPath) as! DefaultCustomCell
cell.titleLabel.text = bodys[indexPath.section][indexPath.row]
cell.selectionStyle = .None
return cell
}
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { }
}
//
// MARK: The table headers
//
class HeaderTableHeaderView: UITableViewHeaderFooterView {
@IBOutlet weak var titleLabel: UILabel!
}
我的意思是它真的很简单。同样,如果我通过 xcode 安装,该应用程序可以正常工作。即使我安装,杀死应用程序,然后重新打开,一切正常。
每当我尝试通过 AdHoc(使用 Diawi)进行安装时,这个愚蠢的东西就会在这个类中崩溃。
【问题讨论】:
-
奇怪的是:rectForFooterInSection,但你没有对页脚做任何事情。也许尝试将 sectionFooterHeight 设置为 0?
标签: ios swift uitableview crash