UITextView键盘回落
来源:互联网 发布:球球大作战开挂软件 编辑:程序博客网 时间:2024/05/01 14:21
在UITextView的键盘中return键是用于换行的,所以不能像UITextField那样点击return来回收键盘。
#import<UIKit/UIKit.h>
@interface FeedBackViewController :UIViewController<UITextViewDelegate>
@property(nonatomic,retain)UITextView *feedBackTV;
@end
@implementation FeedBackViewController
@synthesize feedBackTV;
- (void)viewDidLoad
{
[superviewDidLoad];
self.view = [[[UIViewalloc] initWithFrame:CGRectMake(0,0, 320,460)] autorelease];
//UITextView
self.feedBackTV = [[UITextViewalloc] initWithFrame:CGRectMake(20,65, 280, 300)];
self.feedBackTV.backgroundColor = [UIColorclearColor];
[self.feedBackTV.layersetBorderColor:[[UIColorgrayColor] CGColor]];
[self.feedBackTV.layersetBorderWidth:1.0];
self.feedBackTV.delegate =self;
[self.viewaddSubview:self.feedBackTV];
//键盘上方按钮,用于键盘回落
UIToolbar *topView = [[[UIToolbaralloc]initWithFrame:CGRectMake(0,0, 320,40)] autorelease];
[topViewsetBarStyle:UIBarStyleBlack];
UIBarButtonItem *doneButton = [[UIBarButtonItemalloc]initWithTitle:@"Done"style:UIBarButtonItemStyleDonetarget:selfaction:@selector(dismissKeyBoard)];
NSArray *buttonsArray = [NSArray arrayWithObjects:doneButton,nil];
[doneButton release];
[topView setItems:buttonsArray];
[self.feedBackTVsetInputAccessoryView:topView];
}
#pragma mark - UITextViewDelegate
//开始编辑UITextView时调用的代理方法
- (BOOL)textViewShouldBeginEditing:(UITextView *)textView
{
//开始编辑时使整个视图整体向上移
[UIViewbeginAnimations:@"up"context:nil];
[UIViewsetAnimationDuration:0.5];
[UIViewsetAnimationCurve:UIViewAnimationCurveEaseInOut];
self.view.frame =CGRectMake(0, -40,320, 480);
[UIViewcommitAnimations];
return YES;
}
//键盘回落
- (void)dismissKeyBoard
{
[self.feedBackTVresignFirstResponder];
[UIViewbeginAnimations:@"up"context:nil];
[UIViewsetAnimationDuration:0.5];
[UIViewsetAnimationCurve:UIViewAnimationCurveEaseInOut];
self.view.frame =CGRectMake(0,20, 320, 480);
[UIViewcommitAnimations];
}
- UITextView键盘回落
- UITextView 键盘
- Android 键盘弹起和回落事件监听
- UITextView关闭键盘
- UITextView 取消键盘方法
- UITextView关闭键盘
- UITextView 关闭键盘
- UITextView收起键盘
- UITextView及键盘隐藏
- UITextView 关闭键盘
- UITextView及键盘隐藏
- UITextView键盘操作
- UITextView关闭键盘
- UITextView关闭键盘
- UITextView关闭键盘
- UITextView 回收键盘
- UITextView关闭键盘
- UITextView如何关闭键盘
- delphi 透明
- MP4文件格式解析,及MP4文件的分割算法
- 《网络编程》课本 实验
- linux 抓堆栈 core文件分析
- windows编程------TextOut与TextOutw与TextOutA,基于vs2010
- UITextView键盘回落
- 最终版本NandFlash分区信息
- 3-27java的日子--键盘》文件》控制台的流
- Google code jam: Problem A. Alien Language
- 10670 - Work Reduction
- HDU1325:Is It A Tree?
- 编译-O 选项对性能提升作用
- 分组 背包
- System.Web.UI.Page.RegisterStartupScript(string, string)”已过时的解决办法