UIViewControllerHierarchyInconsistency仅在iOS 8和Xcode 6中崩溃应用程序

UIViewControllerHierarchyInconsistency仅在iOS 8和Xcode 6中崩溃应用程序,第1张

概述我有一个在iOS 7和 Xcode 5中运行良好的应用程序.当我将其更新到iOS 8和Xcode 6时,当应用程序尝试在轻触textField时在视图中向上滑动UIDatePicker时,它会崩溃. 我正在使用故事板. 有谁知道为什么? 我已经阅读了这个,但它的Xib. App crashes on IOS 6 – UIViewControllerHierarchyInconsistency 请帮 我有一个在iOS 7和 Xcode 5中运行良好的应用程序.当我将其更新到iOS 8和Xcode 6时,当应用程序尝试在轻触textFIEld时在视图中向上滑动UIDatePicker时,它会崩溃.
我正在使用故事板.
有谁知道为什么?

我已经阅读了这个,但它的Xib.

App crashes on IOS 6 – UIViewControllerHierarchyInconsistency

请帮忙
谢谢

我的代码:

- (voID)textFIEldDIDBeginEditing:(UITextFIEld *)textFIEld{    //set picker color start    [self.myDatePicker setBackgroundcolor:[UIcolor greencolor]];    //set picker color finish    //calculate bounds start    CGRect textFIEldRect = [self.vIEw.window convertRect:textFIEld.bounds fromVIEw:textFIEld];    CGRect vIEwRect = [self.vIEw.window convertRect:self.vIEw.bounds fromVIEw:self.vIEw];    //calculate bounds finish    //calculate the fraction between the top and bottom of the mIDdle section for the text fIEld's mIDline start    CGfloat mIDline = textFIEldRect.origin.y + 0.5 * textFIEldRect.size.height;    CGfloat numerator = mIDline - vIEwRect.origin.y    - MINIMUM_SCRolL_FRACTION * vIEwRect.size.height;    CGfloat denominator = (MAXIMUM_SCRolL_FRACTION - MINIMUM_SCRolL_FRACTION)    * vIEwRect.size.height;    CGfloat heightFraction = numerator / denominator;    //calculate the fraction between the top and bottom of the mIDdle section for the text fIEld's mIDline finish    //Clamp this fraction so that the top section is all "0.0" and the bottom section is all "1.0 start    if (heightFraction < 0.0)    {        heightFraction = 0.0;    }    else if (heightFraction > 1.0)    {        heightFraction = 1.0;    }    //Clamp this fraction so that the top section is all "0.0" and the bottom section is all "1.0 finish    /*start     Now take this fraction and convert it into an amount to scroll by multiplying by the keyboard height for the current screen orIEntation. Notice the calls to floor so that we only scroll by whole pixel amounts */     UIInterfaceOrIEntation orIEntation =     [[UIApplication sharedApplication] statusbarOrIEntation];     if (orIEntation == UIInterfaceOrIEntationPortrait ||     orIEntation == UIInterfaceOrIEntationPortraitUpsIDeDown)     {     animateddistance = floor(PORTRAIT_KEYBOARD_HEIGHT * heightFraction);     }     else     {     animateddistance = floor(LANDSCAPE_KEYBOARD_HEIGHT * heightFraction);     }     //finish    //Finally,apply the animation start    CGRect vIEwFrame = self.vIEw.frame;    vIEwFrame.origin.y -= animateddistance;    [UIVIEw beginAnimations:nil context:NulL];    [UIVIEw setAnimationBeginsFromCurrentState:YES];    [UIVIEw setAnimationDuration:KEYBOARD_ANIMATION_DURATION];    [self.vIEw addSubvIEw:self.myDatePicker];    [self.vIEw setFrame:vIEwFrame];    [UIVIEw commitAnimations];}    //Finally,apply the animation finish    //Animate back again start

我的崩溃日志

2014-09-14 13:12:52.930 Pay 2014-15 free[2191:83060] *** Terminating app due to uncaught exception 'UIVIEwControllerHIErarchyInconsistency',reason: 'child vIEw controller:<UICompatibilityinputVIEwController: 0x7be0a570> should have parent vIEw controller:<AddHoursVIEwController: 0x7c38e800> but requested parent is:<UIInputwindowController: 0x7c238a00>'*** First throw call stack:(    0   CoreFoundation                      0x02101df6 __exceptionPreprocess + 182    1   libobjc.A.dylib                     0x01d8ba97 objc_exception_throw + 44    2   CoreFoundation                      0x02101d1d +[NSException raise:format:] + 141    3   UIKit                               0x008cff9c -[UIVIEwController _addChildVIEwController:performHIErarchyCheck:notifyWillMove:] + 210    4   UIKit                               0x00f4b44d -[UIInputwindowController changetoinputVIEwSet:] + 576    5   UIKit                               0x00f4c1be __43-[UIInputwindowController setinputVIEwSet:]_block_invoke + 103    6   UIKit                               0x007f73bf +[UIVIEw(Animation) performWithoutAnimation:] + 82    7   UIKit                               0x00f4bf9c -[UIInputwindowController setinputVIEwSet:] + 374    8   UIKit                               0x00ce9101 __64-[UIPeripheralHost(UIKitInternal) setinputVIEws:animationStyle:]_block_invoke1459 + 43    9   UIKit                               0x00f473af -[UIInputwindowController performOperations:withAnimationStyle:] + 56    10  UIKit                               0x00ce9006 -[UIPeripheralHost(UIKitInternal) setinputVIEws:animationStyle:] + 1242    11  UIKit                               0x00ce91df -[UIPeripheralHost(UIKitInternal) setinputVIEws:animated:] + 73    12  UIKit                               0x00ce922b -[UIPeripheralHost(UIKitInternal) setinputVIEws:] + 68    13  UIKit                               0x00ce1478 -[UIPeripheralHost(UIKitInternal) _reloadinputVIEwsForResponder:] + 1803    14  UIKit                               0x0092be95 -[UIResponder(UIResponderinputVIEwAdditions) reloadinputVIEws] + 316    15  UIKit                               0x0092b1dc -[UIResponder becomeFirstResponder] + 562    16  UIKit                               0x007f1de0 -[UIVIEw(HIErarchy) becomeFirstResponder] + 114    17  UIKit                               0x00fb7ffb -[UITextFIEld becomeFirstResponder] + 51    18  UIKit                               0x00bbde8f -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) setFirstResponderIfNecessary] + 200    19  UIKit                               0x00bc04b6 -[UITextInteractionAssistant(UITextInteractionAssistant_Internal) oneFingerTap:] + 2762    20  UIKit                               0x00bb3d27 _UIGestureRecognizerSendActions + 327    21  UIKit                               0x00bb25a4 -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 561    22  UIKit                               0x00bb45ed -[UIGestureRecognizer _delayedUpdateGesture] + 60    23  UIKit                               0x00bb7f6a ___UIGestureRecognizerUpdate_block_invoke661 + 57    24  UIKit                               0x00bb7e2d _UIGestureRecognizerRemoveObjectsFromArrayAndApplyBlocks + 317    25  UIKit                               0x00babd36 _UIGestureRecognizerUpdate + 3720    26  UIKit                               0x007c771b -[UIWindow _sendGesturesForEvent:] + 1356    27  UIKit                               0x007c857f -[UIWindow sendEvent:] + 769    28  UIKit                               0x0078daa9 -[UIApplication sendEvent:] + 242    29  UIKit                               0x0079d8de _UIApplicationHandleEventFromQueueEvent + 20690    30  UIKit                               0x00772079 _UIApplicationHandleEventQueue + 2206    31  CoreFoundation                      0x020257bf __CFRUNLOOP_IS_CALliNG_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15    32  CoreFoundation                      0x0201b2cd __CFRunLoopDoSources0 + 253    33  CoreFoundation                      0x0201a828 __CFRunLoopRun + 952    34  CoreFoundation                      0x0201a1ab CFRunLoopRunspecific + 443    35  CoreFoundation                      0x02019fdb CFRunLoopRunInMode + 123    36  GraphiCSServices                    0x0394624f GSEventRunModal + 192    37  GraphiCSServices                    0x0394608c GSEventRun + 104    38  UIKit                               0x00775e16 UIApplicationMain + 1526    39  Pay 2014-15 free                    0x0014ed7d main + 141    40  libdyld.dylib                       0x0736cac9 start + 1)libc++abi.dylib: terminating with uncaught exception of type NSException(lldb) `enter code here`
解决方法 您可以以编程方式创建日期选择器,或者如果您将其用作拖入组件,请执行以下给定步骤

1.以编程方式创建

datePicker = [[UIDatePicker alloc]init];[datePicker setDate:[NSDate date]];//Nsstring *maxDateString = @"01-Jan-2012";Nsstring *theMinimumDate = @"01-Jan-1976";// the date formatter used to convert string to dateNSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];// the specific format to usedateFormatter.dateFormat = @"dd-MMM-yyyy";// converting string to dateNSDate *theMaximumDate = [NSDate date];//[dateFormatter dateFromString: maxDateString];NSDate *theminimumDate = [dateFormatter dateFromString: theMinimumDate];// repeat the same logic for theMinimumDate if needed// here you can assign the max and min dates to your datePicker[datePicker setMaximumDate:theMaximumDate];//the max age restriction (if needed,or else dont use this line)[datePicker setMinimumDate:theminimumDate]; //the min age restriction// set the mode[datePicker setDatePickerMode:UIDatePickerModeDate];// Do any additional setup after loading the vIEw from its nib.[datePicker addTarget:self action:@selector(updateTextFIEld:) forControlEvents:UIControlEventValueChanged];// and finally set the datePicker as the input mode of your textfIEld[TextfIEld setinputVIEw:datePicker];

2.从Xib

[self.DatePickerVIEw removeFromSupervIEw];[TextfIEld setinputVIEw:self.DatePickerVIEw];[TextfIEld setinputVIEw:self.DatePickerVIEw];
总结

以上是内存溢出为你收集整理的UIViewControllerHierarchyInconsistency仅在iOS 8和Xcode 6中崩溃应用程序全部内容,希望文章能够帮你解决UIViewControllerHierarchyInconsistency仅在iOS 8和Xcode 6中崩溃应用程序所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1056324.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存