UITextView的内容长度限制
2015-07-06 10:40
627 查看
(void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.textView=[[UITextView alloc]initWithFrame:self.view.frame];
self.textView.text=@”请输入文字”;
[self.view addSubview:self.textView];
}
(void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
(void)viewWillAppear:(BOOL)animated
{
//注册通知,监听键盘出现
[[NSNotificationCenter defaultCenter]addObserver:self
selector:@selector(handleKeyboardDidShow:)
name:UIKeyboardDidShowNotification
object:nil];
//注册通知,监听键盘消失事件
[[NSNotificationCenter defaultCenter]addObserver:self
selector:@selector(handleKeyboardDidHidden)
name:UIKeyboardDidHideNotification
object:nil];
[super viewWillAppear:YES];
}
//监听事件
- (void)handleKeyboardDidShow:(NSNotification*)paramNotification
{
//获取键盘高度
NSValue *keyboardRectAsObject=[[paramNotification userInfo]objectForKey:UIKeyboardFrameEndUserInfoKey];
}
(void)handleKeyboardDidHidden
{
self.textView.contentInset=UIEdgeInsetsZero;
}
(void)viewDidDisappear:(BOOL)animated
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.textView=[[UITextView alloc]initWithFrame:self.view.frame];
self.textView.text=@”请输入文字”;
[self.view addSubview:self.textView];
}
(void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
(void)viewWillAppear:(BOOL)animated
{
//注册通知,监听键盘出现
[[NSNotificationCenter defaultCenter]addObserver:self
selector:@selector(handleKeyboardDidShow:)
name:UIKeyboardDidShowNotification
object:nil];
//注册通知,监听键盘消失事件
[[NSNotificationCenter defaultCenter]addObserver:self
selector:@selector(handleKeyboardDidHidden)
name:UIKeyboardDidHideNotification
object:nil];
[super viewWillAppear:YES];
}
//监听事件
- (void)handleKeyboardDidShow:(NSNotification*)paramNotification
{
//获取键盘高度
NSValue *keyboardRectAsObject=[[paramNotification userInfo]objectForKey:UIKeyboardFrameEndUserInfoKey];
CGRect keyboardRect; [keyboardRectAsObject getValue:&keyboardRect]; self.textView.contentInset=UIEdgeInsetsMake(0, 0,keyboardRect.size.height, 0);
}
(void)handleKeyboardDidHidden
{
self.textView.contentInset=UIEdgeInsetsZero;
}
(void)viewDidDisappear:(BOOL)animated
{
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
相关文章推荐
- IOS入门学习笔记(普通UI控件--UIButton)
- kernel build
- unique-paths-ii
- N-Queens DFS
- Arduino Uno 在win7 64位下的驱动问题
- DAX Tabular Calculate,Filter,Value和All
- 优先队列priority_queue 用法详解
- UIDynamicAnimator 小结
- 从源代码的角度聊聊java中StringBuffer、StringBuilder、String中的字符串拼接
- 从源代码的角度聊聊java中StringBuffer、StringBuilder、String中的字符串拼接
- ScrollView中添加一个android:fillViewport="true"(转)
- (PHP 5.3 and above) Please set ‘request_order’ ini value to include C,G and P (recommended: ‘CGP’) i
- [SoapUI] 获取Cookie,并循环遍历当前Project下所有的Test Suite,Test Case,Test Step,将Cookie传递给这些Test Step
- unique-paths
- 详解 UIView 的 Tint Color 属性
- 自定义UI之ActionBar
- Ubuntu更新包管理器失败:Requires installation of untrusted packages问题解决
- Sequence Assignments FRM-41830: List of Value contains no entries.
- 如何自定义 UIPickerView 的行?
- UiAutomator学习笔记