2016-12-09 5 views
2

Ich habe eine UITextView in einer UIView. Als viewLoad hatte ich eine UIPickerView innerhalb einer UIAlertView mit "OK" Taste. Wenn ich einen Wert von Picker und wählen, klicken Sie auf "OK" Ich musste UITextView aktiv machen.
Dafür habe ich [<myTextView> becomeFirstResponder]; Delegate Methode von UITextView geschrieben. Sobald diese Methode ausgeführt wird, wird textViewShouldBeginEditing Delegate-Methode aufgerufen. Diese Methode wird korrekt ausgeführt und ich habe TRUE hier zurück, aber danach geht die Ausführung zurück zur Zeile [<myTextView> becomeFirstResponder]; und dann wird die Anwendung abgestürzt.
UIAlertView Delegate-Methode ist wie folgt:UITextView machen Anwendung Absturz, wenn BeeFirstResponder namens

- (void)customIOS7dialogButtonTouchUpInside: (CustomIOS7AlertView *)alertView clickedButtonAtIndex: (NSInteger)buttonIndex 
{ 
    NSLog(@"Button at position %d is clicked on alertView %d.", (int)buttonIndex, (int)[alertView tag]); 
    [alertView close]; 
    [self.updateTV becomeFirstResponder]; 
} 

Hier in Crash oben Code Anwendung bei [self.updateTV becomeFirstResponder];
Der Crash-Protokoll zeigt:

2016-12-09 11:47:53.069049 oGoing[250:11235] self.viewControllers lastObject ==<OGAddUpdateViewController: 0x17bebe00> 
2016-12-09 11:47:53.069451 oGoing[250:11235] self.viewControllers lastObject ==<OGAddUpdateViewController: 0x17bebe00> 
2016-12-09 11:47:53.070530 oGoing[250:11235] self.viewControllers lastObject ==<OGAddUpdateViewController: 0x17bebe00> 
2016-12-09 11:47:53.070970 oGoing[250:11235] self.viewControllers lastObject ==<OGAddUpdateViewController: 0x17bebe00> 
2016-12-09 11:47:53.071223 oGoing[250:11235] self.viewControllers lastObject ==<OGAddUpdateViewController: 0x17bebe00> 
2016-12-09 11:47:53.072122 oGoing[250:11235] self.viewControllers lastObject ==<OGAddUpdateViewController: 0x17bebe00> 
2016-12-09 11:47:53.132574 oGoing[250:11235] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles 
2016-12-09 11:47:53.136872 oGoing[250:11235] [MC] Reading from public effective user settings. 
2016-12-09 11:47:53.370813 oGoing[250:11235] self.viewControllers lastObject ==<OGAddUpdateViewController: 0x17bebe00> 
2016-12-09 11:47:53.372515 oGoing[250:11235] self.viewControllers lastObject ==<OGAddUpdateViewController: 0x17bebe00> 
2016-12-09 11:47:53.372781 oGoing[250:11235] self.viewControllers lastObject ==<OGAddUpdateViewController: 0x17bebe00> 
2016-12-09 11:47:53.373559 oGoing[250:11235] self.viewControllers lastObject ==<OGAddUpdateViewController: 0x17bebe00> 
2016-12-09 11:47:53.373942 oGoing[250:11235] self.viewControllers lastObject ==<OGAddUpdateViewController: 0x17bebe00> 
2016-12-09 11:47:53.374133 oGoing[250:11235] self.viewControllers lastObject ==<OGAddUpdateViewController: 0x17bebe00> 
2016-12-09 11:47:53.374921 oGoing[250:11235] self.viewControllers lastObject ==<OGAddUpdateViewController: 0x17bebe00> 
2016-12-09 11:47:53.477836 oGoing[250:11235] *** Terminating app due to uncaught exception 'UIViewControllerHierarchyInconsistency', reason: 'child view controller:<UICompatibilityInputViewController: 0x6e208f0> should have parent view controller:<OGAddUpdateViewController: 0x17bebe00> but requested parent is:<UIInputWindowController: 0x17b81400>' 
*** First throw call stack: 
(0x1c38de07 0x1b5f3077 0x1c38dd4d 0x2146dd8b 0x21d43ba3 0x21d448cd 0x213e11bb 0x21d44655 0x21d3d1c9 0x21497b8f 0x213f9153 0x21456e15 0x21457181 0x2157ff83 0x1b04f5 0x287bb5 0x2140895d 0x214088eb 0x213f2a87 0x21408213 0x21407d5f 0x21402947 0x213d37c9 0x21b73c39 0x21b6d8db 0x1c349c8b 0x1c349795 0x1c347a6b 0x1c297073 0x1c296e81 0x1da3fbfd 0x2143eacf 0x21439201 0xed585 0x1ba6250b) 
libc++abi.dylib: terminating with uncaught exception of type NSException 

Helfen Sie mir diese raus. Ich stecke seit 2 Tagen darin fest.
Mein Projekt ist bereits im AppStore und das funktioniert ordnungsgemäß. Aber wenn ich es in iOS 10-Gerät ausführen, erstellt dieses Problem.

Vielen Dank im Voraus

+1

Update Ihr Frage mit Textfeld textViewSoulBouldEditting Methodencode –

+0

Du hast '[ BecomeFirstResponder]; 'zweimal benutzt? –

+0

@ Mr.Bista Nein. Ich habe die Methode einmal verwendet. Und @ Himanshu Moradiya Ich habe UITextView in meinem Code genommen und verwandte Delegate-Methode ist nur "textViewShouldBeginEditing". Daher denke ich, dass die Frage nicht aktualisiert werden muss. –

Antwort

5

starten es funktioniert, während ...

ich vor diesem Problem begegnet.

Problem:

Sie müssen sicherstellen, dass die Ansicht, die Sie inputView oder inputAccessoryView gehören zu keiner übergeordneten Ansicht zuweist. Wenn Sie diese Ansichten von einer XIB in einem ViewController erstellen, werden sie standardmäßig als Subviews einer Superview festgelegt.

Lösung Tipps:

Verwenden Sie die Methode removeFromSuperview auf der Ansicht sind Sie in der inputView zuweisen oder inputAccessoryView

aus: https://stackoverflow.com/a/25882277/3901620

während von xib:

[self.DatePickerView removeFromSuperview]; 
[Textfield setInputView:self.DatePickerView]; 
[Textfield setInputView:self.DatePickerView]; 
Verwandte Themen