我对我的应用程序有一种奇怪的 react 。 我的应用程序在近 10 种不同的设备上运行良好,并且已经通过测试并且已上线。但一位拥有运行 iOS 9.1 的 iPhone 5s 的 friend 遇到了问题。当他尝试进入 TableView 时,我通过使用 alamofire 和 swiftyjson 的 API 调用将项目附加到 TableView 中。应用程序崩溃了。从 crashlytics 我得到这个奇怪的错误
Crashed: com.apple.main-thread
0 Events Near Me 0x1000a532c specialized listMapViewController.tableView(UITableView, cellForRowAtIndexPath : NSIndexPath) -> UITableViewCell (listMapViewController.swift:196)
1 Events Near Me 0x1000a3c94 @objc listMapViewController.tableView(UITableView, cellForRowAtIndexPath : NSIndexPath) -> UITableViewCell (listMapViewController.swift)
2 UIKit 0x18a37220c -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:] + 688
3 UIKit 0x18a372364 -[UITableView _createPreparedCellForGlobalRow:willDisplay:] + 80
4 UIKit 0x18a3617b8 -[UITableView _updateVisibleCellsNow:isRecursive:] + 2440
5 UIKit 0x18a376f0c -[UITableView _performWithCachedTraitCollection:] + 104
6 UIKit 0x18a10f22c -[UITableView layoutSubviews] + 176
7 UIKit 0x18a01f7ac -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 644
8 QuartzCore 0x18981eb58 -[CALayer layoutSublayers] + 148
9 QuartzCore 0x189819764 CA::Layer::layout_if_needed(CA::Transaction*) + 292
10 QuartzCore 0x189819624 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 32
11 QuartzCore 0x189818cc0 CA::Context::commit_transaction(CA::Transaction*) + 252
12 QuartzCore 0x189818a08 CA::Transaction::commit() + 512
13 QuartzCore 0x1898120f8 CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 80
14 CoreFoundation 0x184a47bd0 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
15 CoreFoundation 0x184a45974 __CFRunLoopDoObservers + 372
16 CoreFoundation 0x184a45da4 __CFRunLoopRun + 928
17 CoreFoundation 0x184974ca0 CFRunLoopRunSpecific + 384
18 GraphicsServices 0x18fbb0088 GSEventRunModal + 180
19 UIKit 0x18a08cffc UIApplicationMain + 204
20 Events Near Me 0x100095eec main (AppDelegate.swift:15)
21 libdyld.dylib 0x199da28b8 start + 4
第 196 行是代码
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath) as! locationEventsTableViewCell
var dict = arrRes[indexPath.row]
cell.eventTitle.text = dict["eventName"] as? String //here is the issue
向您解释一下,通过此应用程序,您可以根据您所在的位置获得附近的一些事件。我有一个保护,如果没有事件,就会有一条消息。但是我们离开了几个街区,我可以获取事件,其中包括 cell.eventTitle...但是我 friend 的 iPhone 通过它崩溃了。
有什么想法吗?
附注我现在正在将 iOS 9.1 下载到我的模拟器上。另一位使用 iPhone 5 的 friend 没有这个问题。
最佳答案
正如你所说,其他 iPhone 没有这个问题,我假设你 friend 的 iPhone 可能因应用程序或其他任何东西而重载,并且它没有及时获取 json 变量! 所以我建议首先使用 if 语句来避免这样的错误:
if dict["eventName"] as? String != nil {
cell.eventTitle.text = dict["eventName"] as? String
}
如果您想在下次更新中也许可以使用补全来重新加载 tableView 数据。
希望有帮助。
关于ios - iPhone 应用程序出现奇怪的崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38668169/