Terminating app two to uncaught exception
‘UIVIEwControllerHIErarchyInconsistency’,reason: ‘child vIEw
controller: Should
Have parent vIEw controller: but requested parent is: ‘
这是在ios7中静默工作的代码片段:
expiredPromoTextFIEld.inputVIEw = DatePicker; expiredPromoTextFIEld.delegate = self; quantityPromoTextFIEld.inputVIEw = quantityPicker; quantityPromoTextFIEld.delegate = self; // Create button to close the UIPickerVIEw UIToolbar * mypickerToolbar = [[UIToolbar alloc] initWithFrame: CGRectMake (0,320,56)]; mypickerToolbar.barStyle = UIbarStyleBlackTranslucent; [mypickerToolbar sizetoFit]; NSMutableArray * barItems = [[NSMutableArray alloc] init]; UIbarbuttonItem * CancelBtn = [[UIbarbuttonItem alloc] initWithbarbuttonSystemItem: UIbarbuttonSystemItemCancel target: self action:selector (cancelDoneClicked)]; [barItems addobject: CancelBtn]; UIbarbuttonItem * FLEXspace = [[UIbarbuttonItem alloc] initWithbarbuttonSystemItem: UIbarbuttonSystemItemFlexibleSpace target: self action: nil]; [barItems addobject: FLEXspace]; UIbarbuttonItem * doneBtn = [[UIbarbuttonItem alloc] initWithbarbuttonSystemItem: UIbarbuttonSystemItemDone target: self action:selector (pickerDoneClicked :)]; [barItems addobject: doneBtn]; [mypickerToolbar setItems: barItems animated: YES]; [quantityPicker setShowsSelectionIndicator: YES]; expiredPromoTextFIEld.inputAccessoryVIEw = mypickerToolbar; quantityPromoTextFIEld.inputAccessoryVIEw = mypickerToolbar;
你知道我的意思是inputAccessoryVIEw会崩溃的应用程序,我也问苹果的工程师,他们告诉我,这是测试版的一个问题,但现在与GM继续给同样的问题.
我该怎么办?
解决方法 我在iOS 8上也有同样的例外,现在修正为以下代码.关键是,您不应该添加输入视图作为视图控制器视图的子视图.
(我不知道为什么iOS 7中的代码运行良好,在iOS 8中不再奏效)
之前(发生错误)
UITextFIEld* someTF;VIEw* customVIEw;UIVIEwController *mainVC;[mainVC.vIEw addSubvIEw:customVIEw];someTF.inputVIEw = customVIEw;
之后(工作良好)
UITextFIEld* someTF;VIEw* customVIEw;UIVIEwController *mainVC;// [mainVC.vIEw addSubvIEw:customVIEw]; <-- delete this linesomeTF.inputVIEw = customVIEw;总结
以上是内存溢出为你收集整理的ios – 由于未捕获的异常UIViewControllerHierarchyInconsistency终止应用程序,全部内容,希望文章能够帮你解决ios – 由于未捕获的异常UIViewControllerHierarchyInconsistency终止应用程序,所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)