我在视图中使用UITableviewCell,使用UINib并将其添加到contentView中。
当我从test调试或测试时,我没有发现任何错误,但是Crashlytics有很多崩溃
0x102d20 std::__1::vector<unsigned char, geo::StdAllocator<unsigned char,
ggl::Allocator> >::__append(unsigned long) + 208
1 VectorKit 0x102ce0 std::__1::vector<unsigned char,
geo::StdAllocator<unsigned char, ggl::Allocator> >::__append(unsigned long) + 144
2 VectorKit 0x10b7cc ggl::BufferData::BufferData(unsigned long,
ggl::BufferType, ggl::BufferChange, ggl::BufferUsage, unsigned long) + 196
3 VectorKit 0x200e38
6 VectorKit 0x61eb8 md::MapEngine::updateForConfigurationAndMode() + 1376
7 VectorKit 0xada9c md::MapEngine::MapEngine(float, float, float, bool, VKMapViewPurpose, std::__1::shared_ptr<md::TaskContext> const&, VKMapPurpose, std::__1::unique_ptr<md::AnimationManager, std::__1::default_delete<md::AnimationManager> >, geo::linear_map<md::MapEngineSetting, long long, std::__1::equal_to<md::MapEngineSetting>, std::__1::allocator<std::__1::pair<md::MapEngineSetting, long long> >, std::__1::vector<std::__1::pair<md::MapEngineSetting, long long>, std::__1::allocator<std::__1::pair<md::MapEngineSetting, long long> > > > const&, unsigned long long, GEOApplicationAuditToken*) + 13772
8 VectorKit 0x1070d8 md::MapEngine::interactiveMapEngine(float, bool, VKMapViewPurpose, geo::linear_map<md::MapEngineSetting, long long, std::__1::equal_to<md::MapEngineSetting>, std::__1::allocator<std::__1::pair<md::MapEngineSetting, long long> >, std::__1::vector<std::__1::pair<md::MapEngineSetting, long long>, std::__1::allocator<std::__1::pair<md::MapEngineSetting, long long> > > > const&, unsigned long long, GEOApplicationAuditToken*) + 152
9 VectorKit 0x2619fc -[VKMapView initShouldRasterize:inBackground:contentScale:auditToken:mapViewPurpose:allowsAntialiasing:] + 936
10 MapKit 0x141570 -[MKBasicMapView initWithFrame:andGlobe:shouldRasterize:allowsAntialiasing:] + 388
11 MapKit 0x75094 -[MKMapView _commonInitFromIB:gestureRecognizerHostView:locationManager:showsAttribution:showsAppleLogo:allowsAntialiasing:] + 1668
12 MapKit 0x7606c -[MKMapView initWithCoder:] + 252
13 UIFoundation 0x63588 UINibDecoderDecodeObjectForValue + 704
14 UIFoundation 0x637b4 UINibDecoderDecodeObjectForValue + 1260
15 UIFoundation 0x3a58 -[UINibDecoder decodeObjectForKey:] + 324
16 UIKitCore 0x45cac8 -[UIView initWithCoder:] + 976
17 UIFoundation 0x63588 UINibDecoderDecodeObjectForValue + 704
18 UIFoundation 0x637b4 UINibDecoderDecodeObjectForValue + 1260
19 UIFoundation 0x3a58 -[UINibDecoder decodeObjectForKey:] + 324
20 UIKitCore 0x45cac8 -[UIView initWithCoder:] + 976
21 UIKitCore 0x20310 -[UITableViewCellContentView initWithCoder:] + 48
22 UIFoundation 0x63588 UINibDecoderDecodeObjectForValue + 704
23 UIFoundation 0x637b4 UINibDecoderDecodeObjectForValue + 1260
24 UIFoundation 0x3a58 -[UINibDecoder decodeObjectForKey:] + 324
25 UIKitCore 0x45cac8 -[UIView initWithCoder:] + 976
26 UIKitCore 0xddd54 -[UITableViewCell initWithCoder:] + 100
27 0x20b8c8 init + 45 (LocationFieldTableViewCell.swift:45)
28 0x20ad98 init + 4341656984 (<compiler-generated>:4341656984)
29 UIKitCore 0x414d3c -[UIClassSwapper initWithCoder:] + 2120
30 UIFoundation 0x63588 UINibDecoderDecodeObjectForValue + 704
31 UIFoundation 0x3a58 -[UINibDecoder decodeObjectForKey:] + 324
32 UIKitCore 0x592ba8 -[UIRuntimeConnection initWithCoder:] + 132
33 UIFoundation 0x63588 UINibDecoderDecodeObjectForValue + 704
34 UIFoundation 0x637b4 UINibDecoderDecodeObjectForValue + 1260
35 UIFoundation 0x3a58 -[UINibDecoder decodeObjectForKey:] + 324
36 UIKitCore 0x595468 -[NSCoder(UIIBDependencyInjectionInternal) _decodeObjectsWithSourceSegueTemplate:creator:sender:forKey:] + 492
37 UIKitCore 0x5343e4 -[UINib instantiateWithOwner:options:] + 1052
38 0x209168 instanceFromNib + 74 (LocationFieldTableViewCell.swift:74)发布于 2022-11-17 03:14:40
让表视图通过在表视图中注册nib来为您创建单元格。这使表视图只创建填充屏幕所需的实例数。例如:
class ViewController: UITableViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Assuming a nib exists named LocationFieldTableViewCell in the main bundle
let nib = UINib(nibName: "LocationFieldTableViewCell", bundle: .main)
tableView.register(nib, forCellReuseIdentifier: "my-id")
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "my-id", for: indexPath) as? LocationFieldTableViewCell
// configure cell
return cell
}
}阅读UITableView和单元重用是如何工作的!
就崩溃而言,您可能可以通过以下指南获得更多信息:https://developer.apple.com/news/?id=nra79npr
这将让您浏览代码并查看代码崩溃的位置,很可能是nib中的一些东西没有正确解码--看看日志(LocationFieldTableViewCell.swift:74),LocationFieldTableViewCell.swift的第74行是什么?这可能就是问题所在。
https://stackoverflow.com/questions/74467113
复制相似问题