child view controller: should have parent view controller: but requested parent is:

iOS 11.0出现的崩溃。

其他版本未出现崩溃。

原因:

之前代码不规范,将childViewController上的View添加当前视图,但是未添加childVC

[self.view addSubview:self.childVC.view];

应添加

[self addChildViewController:self.childVC];
 [self.view addSubview:self.childVC.view];

崩溃信息

Device Version: iPhone 6S
iOS Version: 11.0
App Version: 6.8.6
Build Version: 6.8.6.0.1
ibuild Build Version: 001163
ibuild Build Date Time: 2017-09-08 11:40:34
Crash Date Time: 2017-09-08 17:20:45
================================
Name: UIViewControllerHierarchyInconsistency
Reason: child view controller: should have parent view controller: but requested parent is:
UserInfo: (null)


CallStackSymbols:
0 CoreFoundation 0x0000000185917d50 + 148
1 libobjc.A.dylib 0x0000000184e2c528 objc_exception_throw + 56
2 CoreFoundation 0x0000000185917c80 + 0
3 UIKit 0x000000018ed41320 + 304
4 UIKit 0x000000018f832270 + 544
5 UIKit 0x000000018f82bdf8 + 568
6 UIKit 0x000000018f83320c + 1108
7 UIKit 0x000000018f82b7cc + 56
8 UIKit 0x000000018ed60c60 + 1176
9 UIKit 0x000000018ecd1440 + 2140
10 UIKit 0x000000018ecd0bb4 + 80
11 UIKit 0x000000018ed2ca28 + 856
12 UIKit 0x000000018ed5e45c + 760
13 UIKit 0x000000018ed5d6b4 + 788
14 UIKit 0x000000018ed53c18 + 2520
15 UIKit 0x000000018ed52d08 + 1168
16 UIKit 0x000000018ed52770 + 124
17 UIKit 0x000000018ed52698 + 188
18 UIKit 0x000000018eca8d70 + 1256
19 QuartzCore 0x00000001898dbcc8 + 184
20 QuartzCore 0x00000001898dfda8 + 332
21 QuartzCore 0x000000018984fb50 + 336
22 QuartzCore 0x0000000189875f6c + 540
23 UIKit 0x000000018ec9e5f4 + 256
24 CoreFoundation 0x00000001858bf8b8 + 32
25 CoreFoundation 0x00000001858bd270 + 412
26 CoreFoundation 0x00000001858bd82c + 1292
27 CoreFoundation 0x00000001857de2d8 CFRunLoopRunSpecific + 436
28 GraphicsServices 0x0000000187663f84 GSEventRunModal + 100
29 UIKit 0x000000018ed0f5e0 UIApplicationMain + 208
30 xxxxx 0x000000010095a470 main + 164
31 libdyld.dylib 0x000000018530256c + 4


最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 转自http://www.raywenderlich.com/zh-hans/30818/ios应用崩溃日志揭秘 ...
    RunSnails阅读 4,494评论 2 22
  • 异常编码 在研究真实闪退场景之前,还有一点需要重点介绍一下:就是那些有趣的异常编码 。 你可以在报告的异常部分——...
    中二修行者阅读 1,896评论 0 3
  • 咯莫
    小Sun1234阅读 161评论 0 0
  • 不知道从什么时候起,我开始给您过母亲节了,形式不外乎请您和老爸一起到外面去吃顿饭,或买束鲜花、或在家里为您做...
    莲子清清阅读 509评论 3 3
  • 今晚夜班,今天天气不错,单位也不是太忙,7点多吃完饭了,女儿给我打电话问问我吃饭了没有?她说今天在托辅把作业都写完...
    海浪花_2642阅读 124评论 0 0