我有一個UITextView
可編輯時,出現選擇鍵盤。問題是,當文字太大時,他會躲在鍵盤後面。我怎麼解決這個問題?IPhone TextView隱藏鍵盤
0
A
回答
2
這段代碼移動視圖了
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
//change origin y
[UIView beginAnimations:nil context:self.view];
[UIView setAnimationDuration:0.25];
[self.view setFrame:CGRectMake(0,-150,320,436)];
[UIView commitAnimations];
}
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField
{
//reset origin y
[UIView beginAnimations:nil context:self.view];
[UIView setAnimationDuration:0.25];
[self.view setFrame:CGRectMake(0,0,320,436)];
[UIView commitAnimations];
}
根據您的要求設置x和y值。
+0
真的很有幫助;)。 –
0
此問題已被多次詢問。在發佈問題前請做一些Google搜索。無論如何...
請參閱this question由別人提問,並已成爲社區wiki。在這個問題上發佈了31個答案。
此外,您還可以與this tutorial
0
變化基本視圖大小協商時編輯的UITextField,降低基本視圖淵源考原點Y編輯文本字段
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
//change origin y
}
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField
{
//reset origin y
}
0
使用UITextfield
的委託方法。
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
[UIView beginAnimations:nil context:self.view];
[UIView setAnimationDuration:duration];
//change origin y
[self.view setFrame:CGRectMake(X,newY,width,height)];
[UIView commitAnimations];
}
- (BOOL)textFieldShouldEndEditing:(UITextField *)textField
{
[UIView beginAnimations:nil context:self.view];
[UIView setAnimationDuration:duration];
//reset origin y
[self.view setFrame:CGRectMake(X,Y,width,height)];
[UIView commitAnimations];
}
不要忘記設置UITextFieldDelegate在您的「.H」文件和相應的文本的Fileds textfiled.delegate = self
。
相關問題
- 1. TextView與鍵盤隱藏
- 2. iPhone - 鍵盤隱藏TextField
- 3. 隱藏鍵盤iphone sdk?
- 4. 隱藏iPhone上的鍵盤
- 5. 鍵盤在android的webview中隱藏textview
- 6. uitextfield隱藏鍵盤?
- 7. 隱藏鍵盤
- 8. 隱藏鍵盤
- 9. iPhone鍵盤在UIWebView中隱藏字段
- 10. 在iPhone中隱藏數字鍵盤
- 11. 隱藏iPhone的鍵盤使用Javascript
- 12. 從視圖隱藏iPhone鍵盤
- 13. iphone:鍵盤是不是隱藏
- 14. UITextView在iphone中隱藏鍵盤
- 15. 在iphone中取消隱藏鍵盤
- 16. 隱藏Iphone鍵盤丟失焦點
- 17. iPhone鍵盤不隱藏在設備上
- 18. 沒有textview的iphone鍵盤
- 19. 隱藏鍵盤ios
- 20. 隱藏軟鍵盤
- 21. 隱藏IOS鍵盤
- 22. 鈦 - 隱藏鍵盤
- 23. 鍵盤隱藏BottomSheetDialogFragment
- 24. Iphone隱形鍵盤
- 25. 隱藏軟鍵盤或強制改變焦點隱藏鍵盤
- 26. 辭職急救員隱藏鍵盤,但不生成鍵盤將隱藏/鍵盤確實隱藏事件
- 27. Android鍵盤隱藏屏幕
- 28. 隱藏鍵盤/ resignFirstResponder強制
- 29. 軟鍵盤隱藏的EditText
- 30. Nativescript Android - 隱藏鍵盤
您應該在出現KeyBoard時向上滾動視圖。使用本教程實現它http://www.cocoawithlove.com/2008/10/sliding-uitextfields-around-to-avoid.html – Sumanth
[如何使UITextField在鍵盤存在時向上移動](http ://stackoverflow.com/questions/1126726/how-to-make-a-uitextfield-move-up-when-keyboard-is-present) – paulmelnikow