我havng一个文本框和两个textViews ...在写入东西在1 conrol键盘被强行...但是当我想转移到另一个控制我的键盘doesn'不要让我写,因为它涵盖了整个视图......我能解决我的问题吗?键盘不会从视图中消失iphone
回答
提供的UITextView和uitextfiled使用委托功能....
我已经尝试了一件事...我已经采取了我的整个视图上的按钮....所以,每当我点击我的任何部分视图,键盘将消失...我用“ self.resignResponder“...但不工作.....你能以其他方式建议我吗? – 2012-01-16 13:10:32
它应该是[textField resignFirstResponder] – vishy 2012-01-16 13:20:30
而不是self.resign响应者,您必须从uitextfield或uitextview中退出响应者。或使用基于ios的uitextfield或textview检出任何教程.. – Ballu 2012-01-16 13:21:05
- (void) animateTextField: (UITextField*) textField up: (BOOL) up
{
const int movementDistance = 150; // tweak as needed
const float movementDuration = 0.3f; // tweak as needed
int movement = (up ? -movementDistance : movementDistance);
[UIView beginAnimations: @"anim" context: nil];
[UIView setAnimationBeginsFromCurrentState: YES];
[UIView setAnimationDuration: movementDuration];
self.view.frame = CGRectOffset(self.view.frame, 0, movement);
[UIView commitAnimations];
}
- (BOOL)textViewShouldBeginEditing:(UITextView *)textView{
[self animateTextField: textField up: YES];
}
- (void)textViewDidEndEditing:(UITextView *)textView{
[self animateTextField: textField up: NO];
}
你应该将你的观点了,使键盘犯规覆盖文本框/ TextView的。这样的事情...
- (void)textFieldDidBeginEditing:(UITextField *)textField
{
if (textField == *textFieldName*)
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:0.5];
[UIView setAnimationBeginsFromCurrentState:YES];
self.view.frame = CGRectMake(self.view.frame.origin.x, (self.view.frame.origin.y - 65.0), self.view.frame.size.width, self.view.frame.size.height);
[UIView commitAnimations];
}
}
- (void)textFieldDidEndEditing:(UITextField *)textField
{
if (textField == *textFieldName*)
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:0.5];
[UIView setAnimationBeginsFromCurrentState:YES];
self.view.frame = CGRectMake(self.view.frame.origin.x, (self.view.frame.origin.y + 65.0), self.view.frame.size.width, self.view.frame.size.height);
[UIView commitAnimations];
}
}
和TextView的使用:
- (void)textViewDidBeginEditing:(UITextView *)textView
和
- (void)textViewDidEndEditing:(UITextView *)textView
你可以改变你的整个视图向上或只是移动控件(文本字段,文本视图)向上..或使您的视图可滚动,以便用户可以向下滚动,而键盘可见。
但键盘覆盖第二个控制器... – 2012-01-17 04:16:59
即使如此..您可以将所有控件添加到滚动视图中,因此如果用户使用键盘滚动屏幕可见他将能够看到其他控件 – 2012-01-17 13:39:29
- 1. UIWebView中的iPhone键盘不会消失
- 2. iPhone键盘在视图消失后消失
- 3. UITextField键盘不会消失
- 4. iOS键盘不会消除视图后消失
- 5. iOS键盘制作视图消失
- 6. 使用iScroll时,键盘不会消失
- 7. Android软键盘不会消失
- 8. 键盘不会消失时攻丝UIPickerView
- 9. 当我在iPhone上按“完成”时键盘不会消失
- 10. 从视图隐藏iPhone键盘
- 11. 软键盘不会在图形视图
- 12. 键盘在iPhone不会?
- 13. iphone键盘不会出现
- 14. iOS 10.0 Beta,键盘扩展:消失的数字键盘(iPhone)
- 15. 如何在视图中隐藏键盘消失或点击按钮iphone
- 16. 当UIImagePicker出现时,iPhone键盘会消失
- 17. 键盘不会消除
- 18. 向上移动一个视图,使textfield不会消失在键盘后面
- 19. EditText键盘消失
- 20. 视图会消失不会触发
- 21. JSQMessages键盘不会推高视图
- 22. 桌面视图中的两个TextField在滚动视图中全部在键盘出现时消失iPhone
- 23. MFMailComposeViewController不从视图中消失
- 24. UITextField的键盘不会消失。不,真的
- 25. iPhone键盘调整在视图
- 26. 回收视图不会消失
- 27. iOS视图在键盘消失后自动向下移动
- 28. 动画iOS键盘消失与视图控制器
- 29. 如何重新定位Web视图键盘消失后?
- 30. 我无法让用户界面文本视图键盘消失
你的意思是说键盘掩盖了你的文本字段?这是你的问题吗? – 2012-01-16 13:13:04
是的。这也是一个问题 – 2012-01-17 04:16:17
@khushbu,你需要先学习目标的基本知识c。使用[this](http://iphonesdkbasics.blogspot.com/2010/01/disabling-keyboard-on-uitextfield.html )函数来禁用uitextfield的键盘,并通过触摸事件来隐藏uitextview的键盘,因为它不会使用返回键禁用。另外,请尝试[这,我认为这是你会喜欢的。](http:// stackoverflow。 com/questions/1126726/how-to-make-a-uitextfield-move-up-when-keyboard-is-present) – Sarah 2012-01-16 13:10:36