iphone隐藏键盘代码
来源:互联网 发布:嵌入式linux如何调试 编辑:程序博客网 时间:2024/06/05 17:00
在View中使用UITextField时,经常需要输入完成后,隐藏键盘~~怎么实现呢?
要让ViewController实现UITextFieldDelegate代理,然后重写部分方法。
---------@interface ViewController---------
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController<UITextFieldDelegate>
@property(nonatomic,retain) UILabel *label;
@property(nonatomic,retain) UIButton *button;
@property(nonatomic,retain) UITextField *txtField;
-(IBAction)changeLabel:(id)sender;
@end
---------ViewController.m---------
指定文本框的代理:
- (void)viewDidLoad
{
[super viewDidLoad];
txtField.delegate = self;//一定要指定代理,往往在这里容易出现错误
}
--------点击Enter的时候隐藏键盘-------
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
return YES;
}
--------点击view其他区域隐藏键盘--------
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[txtField resignFirstResponder];
}
- Iphone隐藏键盘代码
- Iphone隐藏键盘代码
- iphone隐藏键盘代码
- Iphone隐藏键盘代码[转]
- 九十三、编写 代码 隐藏 iPhone键盘
- iphone--UIWebView隐藏键盘
- iPhone简单实现键盘隐藏
- iOS隐藏键盘代码
- iOS隐藏键盘代码
- iOS隐藏键盘代码
- iphone中隐藏虚拟键盘的实现
- iphone中键盘的显示和隐藏
- Android 代码隐藏手机键盘
- iPhone获取键盘高度,通知方式隐藏和显示键盘
- android隐藏虚拟键盘的代码参考
- IPhone开发 IPad使用UIModalPresentationFormSheet时隐藏键盘
- iPhone界面上文本输入时隐藏键盘
- iPhone开发笔记 退回输入键盘:自定义颜色:隐藏状态栏:
- UITableViewController及UITableView
- 沙盒中的文件操作
- 从plist文件读取列表数据并添加索引
- ASIHTTPRequest ASIDownloadCache
- ASIHTTPRequest类库简介及使用
- iphone隐藏键盘代码
- UITextFieldDelegate中方法说明
- ASIHTTPRequest用法
- iPhone loadView 和 viewDidLoad的区别
- #pragma mark
- UITextView用法
- 黑马程序员 Java基础<四>---> 异常
- clearButtonMode
- iphone/ipad:如何编程得到屏幕宽度?