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,460評論 2 22
  • 異常編碼 在研究真實閃退場景之前,還有一點需要重點介紹一下:就是那些有趣的異常編碼 。 你可以在報告的異常部分——...
    中二修行者閱讀 1,843評論 0 3
  • 咯莫
    小Sun1234閱讀 158評論 0 0
  • 不知道從什么時候起,我開始給您過母親節了,形式不外乎請您和老爸一起到外面去吃頓飯,或買束鮮花、或在家里為您做...
    蓮子清清閱讀 500評論 3 3
  • 今晚夜班,今天天氣不錯,單位也不是太忙,7點多吃完飯了,女兒給我打電話問問我吃飯了沒有?她說今天在托輔把作業都寫完...
    海浪花_2642閱讀 118評論 0 0