博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【转】UITextView检查已输入字符字数
阅读量:4552 次
发布时间:2019-06-08

本文共 506 字,大约阅读时间需要 1 分钟。

- (void)textViewDidChange:(UITextView *)textView {

    NSInteger number = [textView.text length];
    if (number > 128) {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"字符个数不能大于128" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil];
        [alert show];
        textView.text = [textView.text substringToIndex:128];
        number = 128;
        [alert release];
    }
//    self.statusLabel.text = [NSString stringWithFormat:@"%d/128",number];
}

转载于:https://www.cnblogs.com/wengzilin/archive/2012/03/26/2417480.html

你可能感兴趣的文章
HDOJ_就这么个烂题总是WA先放这把
查看>>
十大经典官场小说
查看>>
uva 101 POJ 1208 The Blocks Problem 木块问题 vector模拟
查看>>
Python 面向对象 特殊方法(魔法方法)
查看>>
[转]OData/WebApi
查看>>
[转]高颜值、好用、易扩展的微信小程序 UI 库,Powered by 有赞
查看>>
[转]SQL Server如何启用xp_cmdshell组件
查看>>
[转]微擎应用笔记3--manifest.xml文件使用说明
查看>>
Codeforces 1000C Covered Points Count 【前缀和优化】
查看>>
python高效读取文件、文件改写
查看>>
gulp
查看>>
pgsql查询优化之模糊查询
查看>>
[转]-Gradle使用手册(三):构建任务
查看>>
ExtJS下拉树
查看>>
android 调用系统相机录像并保存
查看>>
BW系统表的命名规则
查看>>
Asp.Net在IE10下出现_doPostBack未定义的解决办法 LinkButton
查看>>
《CLR via C#》Part2之Chapter5 基元类型、引用类型和值类型(一)
查看>>
1-9 RHEL7-文件权限管理
查看>>
apache服务器安装
查看>>