UItextview与UItextfield的区别及uitextview用法

来源:互联网 发布:app相册制作软件 编辑:程序博客网 时间:2024/05/21 10:27

IOS中的UITextView和UITextField都是文本输入控件并都能够调用系统键盘。

UITextField :

只能输入一行,不可以滚动显示浏览全文,可以设置提醒文字(有placeholder属性),有占位,继承自UIView[UIControl]

UITextView:

能输入多行,可以滚动显示浏览全文,不可以设置提醒文字(没有placeholder属性),无占位,继承自UIScrollView


占位:UIBarButtonSystemItemFlexibleSpace


IOS中常常需要有限制用户输入字数的要求

1,UITextView
我们可以在- (void)textViewDidChange:(UITextView *)textView[检测到输入变化的时候执行]和
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text[超过一定字数返回NO即可]

2,UITextField

简单的方法只能在 - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string; 方法中处理。


uitextfield


链接:http://www.jianshu.com/p/889a87595a51


uitextview


链接:http://www.jianshu.com/p/14385b1db4f3

原创粉丝点击