2013-09-21 42 views
2

這裏有一個很奇怪的問題,這種情況沒有發生的iOS 7 ...僵局的UITextView [iOS的7]

之前我有在我創建了一個形式的UITextField和UITextView的。 ..問題是,如果用戶有文本字段作爲第一響應,然後點擊uitextview發生死鎖,內存將增加,直到看門狗殺死我的應用程序..

這不會發生,當我從uitextview更改爲uitextfield

相關代碼:

#pragma mark - UITextView Delegate 
-(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text { 

if ([text isEqualToString:@"\n"]) { 
    [textView resignFirstResponder]; 
} 

NSUInteger newLength = [textView.text length] + [text length] - range.length; 

return (newLength > 120) ? NO : YES; 

} 

-(void)textViewDidEndEditing:(UITextView *)textView { 

if (textView.tag == CreatePlaceElementDescription) { 
    self.marker.info = textView.text; 
} 
else if (textView.tag == CreatePlaceElementAddress) { 
    self.marker.address = textView.text; 
} 
} 

#pragma mark - UITextField Delegate 
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { 

if ([string isEqualToString:@"\n"]) { 
    [textField resignFirstResponder]; 
} 

NSUInteger newLength = [textField.text length] + [string length] - range.length; 

//Limit name textfield length 
return (newLength > 60) ? NO : YES; 
} 

-(void)textFieldDidEndEditing:(UITextField *)textField { 

if (textField.tag == CreatePlaceElementName) { 
    self.marker.name = textField.text; 
} 

} 

沒有什麼更多的這個比...

,如果我辭職第一響應者首先就不會發生這個問題,但它將使用戶輕按兩次TextView的,這是不想要的..

也僵局發生在TextView的:didEndEditing,(好像TextView的是一個辭職的鍵盤不是文本框,文本框:didEndEditing也叫).. TextView的:didEndEditing不應該在任何地方叫

真的博格爾斯我的想法...有什麼建議?

+0

任何原因我被downvoted?請有幫助,並至少告訴我在哪種方式我錯了...我已經全面測試了我的所有應用程序,並且這個錯誤真的讓我心動不已。 –

回答

0

好吧,我得到了什麼問題

我使用DaKeyboardControl鍵盤出現時,調整的意見... ...什麼是奇怪的是,似乎這是iOS上的7改變第一反應時(它不會破當只有一個textview/textfield存在時進入死鎖)...我打開一個BUG報告給他們的githubs,而我認爲哪一行產生這個錯誤...當我有它,我會分享它編輯你

編輯:問題是在UIKeyboardWillShowNotification接收器...這個通知被調用多次...解決方案似乎是使用UIKeyboardDidChangeFrameNotification或UIKeyboardWillChangeFrameNotification來p erform幀的變化...

我希望這可以幫助別人...不知道如果用UIKeyboardWillShowNotification會出現問題,不使用的是iOS 7現在

+0

你是如何改變使用DAKeyboardControl的不同通知的? –

+0

對不起,我遲到的迴應,這裏是.h http://pastebin.com/xwRE7MCw,這裏是.m修改版本http://pastebin.com/kzBx7b6r,我給你這個,因爲我還添加了一些BOOLeans到知道什麼時候鍵盤沒有使用猴子補丁,通知的魔術發生在addKeyboardControl和removeKeyboardControl(註釋行)問候! –

1

我只是設法解決它的人通過修改DAKeyboardControl.m中的方法inputKeyboardDidShow,如下所示:

- (void)inputKeyboardDidShow 
{ 
    // Grab the keyboard view 
    if(self.keyboardActiveInput.inputAccessoryView.superview){ 
     self.keyboardActiveView = self.keyboardActiveInput.inputAccessoryView.superview; 
     self.keyboardActiveView.hidden = NO; 
    } 

    // If the active keyboard view could not be found (UITextViews...), try again 
    if (!self.keyboardActiveView) { 
     // Find the first responder on subviews and look re-assign first responder to it 
     [self reAssignFirstResponder]; 
    } 
}