UITextView 实现 placeholder 及隐藏键盘
来源:互联网 发布:美工的就业前景 编辑:程序博客网 时间:2024/05/24 01:25
#import <Foundation/Foundation.h>
@interface UIPlaceHolderTextView : UITextView {
@private
}
@property(nonatomic, retain) UILabel *placeHolderLabel;
@property(nonatomic, retain) NSString *placeholder;
@property(nonatomic, retain) UIColor *placeholderColor;
-(void)textChanged:(NSNotification*)notification;
@end
#import "UIPlaceHolderTextView.h"
@implementation UIPlaceHolderTextView
@synthesize placeHolderLabel;
@synthesize placeholder;
@synthesize placeholderColor;
- (void)dealloc
{
}
- (void)awakeFromNib
{
}
- (id)initWithFrame:(CGRect)frame
{
}
- (void)textChanged:(NSNotification *)notification
{
}
- (void)setText:(NSString *)text {
}
- (void)drawRect:(CGRect)rect
{
}
@end
//隐藏键盘,实现UITextViewDelegate
-(BOOL)textView:(UITextView *)textViewshouldChangeTextInRange:(NSRange)range replacementText:(NSString*)text
{
uitextview键盘处理以及字数限制
#pragma ################# textView delegate ###################
- (BOOL)textView:(UITextView*)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString*)text
{
if(1== range.length) {
//按下回格键
returnYES;
}
if([text isEqualToString:@"\n"]) {//按下return键
//这里隐藏键盘,不做任何处理
[textView resignFirstResponder];
returnNO;
}else{
if([textView.textlength] < 30) {//判断字符个数
returnYES;
}
}
returnNO;
}
- (BOOL)textViewShouldBeginEditing:(UITextView*)textView
{
if(_is_first_load){
textView.text=nil;
_is_first_load=false;
}
returnYES;
}
- (void)textViewDidChange:(UITextView*)textView
{
intlenth=[textView.textlength];//字数
NSString*_txt_conten=nil;
if(lenth>30){
_txt_conten=[textView.textsubstringToIndex:30];
}
else{
_txt_conten=textView.text;
}
textView.text=_txt_conten;
NSString*txt_length=[NSStringstringWithFormat:@"%d/30",_txt_conten.length];
lbl_count.text=txt_length;
}
- UITextView 实现 placeholder 及隐藏键盘
- UITextView及键盘隐藏
- UITextView及键盘隐藏
- UITextView及键盘隐藏
- UITextView 委托及键盘隐藏
- UITextView实现自动隐藏键盘,自动隐藏键盘
- IOS UITextView实现自动隐藏键盘
- UITextView实现 return键隐藏键盘
- UITextView和UITextField的placeholder,键盘隐藏,键盘换行变完成字样
- UITextView 实现placeholder
- UITextView实现placeholder
- UITextView实现Placeholder功能
- UITextView 实现 placeholder
- 实现UITextView的placeholder及限制输入次数(干货)
- UITextView 实现placeholder的方法
- UITextView 实现placeholder的方法
- UITextView 实现placeholder的方法
- iOS 实现UITextView的placeholder
- iPhone开发学习笔记——Core Data 框架及运作过程和设计的类
- 产品设计“九步法”
- Codeforces Beta Round #1
- PL/SQL Developer连接oracle数据库方法
- Android有效解决加载大图片时内存溢出的问题
- UITextView 实现 placeholder 及隐藏键盘
- iOS本地通知和远程通知
- ContextImpl getSysteService
- 将工程转成 arc
- 阻塞和非阻塞通信
- 在CodeBlocks环境下使用boost库
- 我看TechEd 2012之技术热点
- Linux Make(Makefile)由浅入深的学习与示例剖析
- 异常向量表