UITextField限制个数,没用代理
2016-06-12 14:00
387 查看
_textField = [[UITextField
alloc]initWithFrame:CGRectMake(15,
10,
SCREENWIDTH-30,
50)];
_textField.placeholder =
@"美食宣言";
_textField.font = [UIFont
systemFontOfSize:13];
_textField.autocorrectionType =
UITextAutocorrectionTypeNo;
_textField.clearButtonMode =
UITextFieldViewModeWhileEditing;
[_textField
addTarget:self
action:@selector(textFieldDidChange:)
forControlEvents:UIControlEventEditingChanged];
[self.view
addSubview:_textField];
- (void)textFieldDidChange:(UITextField *)textField
{
if (textField.text.length >
99) {
textField.text = [textField.text
substringToIndex:99];
UIAlertView *aler=[[UIAlertView
alloc]initWithTitle:@"提醒"
message:@"最多可输入99字"
delegate:self
cancelButtonTitle:@"确定"
otherButtonTitles:
nil];
[aler show];
}
}
alloc]initWithFrame:CGRectMake(15,
10,
SCREENWIDTH-30,
50)];
_textField.placeholder =
@"美食宣言";
_textField.font = [UIFont
systemFontOfSize:13];
_textField.autocorrectionType =
UITextAutocorrectionTypeNo;
_textField.clearButtonMode =
UITextFieldViewModeWhileEditing;
[_textField
addTarget:self
action:@selector(textFieldDidChange:)
forControlEvents:UIControlEventEditingChanged];
[self.view
addSubview:_textField];
- (void)textFieldDidChange:(UITextField *)textField
{
if (textField.text.length >
99) {
textField.text = [textField.text
substringToIndex:99];
UIAlertView *aler=[[UIAlertView
alloc]initWithTitle:@"提醒"
message:@"最多可输入99字"
delegate:self
cancelButtonTitle:@"确定"
otherButtonTitles:
nil];
[aler show];
}
}
相关文章推荐
- 对AlertDialog.Builder进行封装
- (Builder)建造者模式的Java实现
- Redhat 官方Performance_Tuning_Guide
- UIlabel顶端对齐
- UI控件用法
- 这个函数的返回 值value的二进制位模式从左到右翻转后的值。
- C# StructLayout(LayoutKind.Sequential)]
- UITextField的基本使用
- Crank Storyboard Suite汽车仪表盘设计
- SecrueCRT 方向键不能使用
- easyui formatter实现超链接效果
- UIButton中setTitleEdgeInsets和setImageEdgeInsets的使用
- Android UI-开源框架ImageLoader的完美例子
- UIViewContentMode各类型效果
- 浅谈如何实现easyui的datebox格式化
- POJ-1458 Common Subsequence
- UI各种效果库
- Android基础UI组件
- UILabel的行间距
- UIView 中的控件事件穿透 Passthrough 的实现