我在选择器上方创建了一个带有两个按钮的工具栏,并在 ios7 上工作,当我在 ios8 崩溃中运行时:
终止应用程序二未捕获的异常'UIViewControllerHierarchyInconsistency',原因:'子视图控制器:应该有父视图控制器:但请求的父是:'
这是在 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, 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
会导致应用程序崩溃,我还询问了 Apple 的工程师,他们告诉我这是 beta 版的问题,但现在 GM 继续给出同样的问题。
我该怎么办?