ios - 给textview添加placeholder属性问题
PHP中文网
PHP中文网 2017-04-18 09:46:56
0
5
537

**需求比较特殊,textview是放在每个cell上面的,cell有好几行
不知道如何下手 最主要的是cell还是用的XIB创建的
如果开始编辑时让textview.text==@”“ 结果是全部的textview都等于空**

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(5)
Ty80

There are two ways to solve this problem:
1. Find a third party
2. Add a layer of UIlabel to the textview yourself and then implement the textview's delegate. Once the question is entered, hide the uilabel
No input or the number of characters entered is 0 Just show. There is also a way to add a gesture tap to UILable and then detect whether input is needed to achieve the function you want

Mainly

-(void)textViewDidBeginEditing:(UITextView *)textView{
    if (!UIlabel.text.length) {
        UIlabel.hidden = NO;
    }else{
        UIlabel.hidden = YES;
    }  
}
-(void)textViewDidEndEditing:(UITextView *)textView{
    if (!UIlabel.text.length) {
        UIlabel.hidden = NO;
    }else{
        UIlabel.hidden = YES;
    }  
    
}
-(void)textViewDidChange:(UITextView *)textView{
    //字数限制可以在这里
    
}
-(BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text{
   
    return YES;
}

Big move: I wrote a temp. I will imitate your interface at night and correct it. The logic is complete
Link description

巴扎黑

Is it possible to use the model to define the displayed placeholder text? When using cellForRow, take out the placeholder and assign it to the TextView.

迷茫

And the most important thing is that an area of ​​the project can be increased infinitely

左手右手慢动作

Why is it necessary to have TextView? TextFiled can’t meet your needs?

伊谢尔伦

Don’t directly manipulate the view, manipulate the data, just refresh it

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!