UITextField的代理方法

- (void)textFieldDidBeginEditing:(UITextField *)textField

当textField开始编辑的时候调用,可用完成如下的需求:点击textField可以使页面往上滑动 必须加上这句代码

[UIView animateWithDuration:.25 animations:^{

_scrollView.contentOffset = CGPointMake(0, 75);

}];

- (void)textFieldDidEndEditing:(UITextField *)textField

当textField编辑完成,点击键盘时调用的方法,可以使页面滑动到原来的位置,必须加上这句代码

[UIView animateWithDuration:.25 animations:^{

_scrollView.contentOffset = CGPointMake(0, 0);

}];

博主属于菜鸟,只能从点滴做起,望大神指点。博客写的很烂,但是也得硬着头皮发!!!

时间: 2024-08-09 02:12:46

UITextField的代理方法的相关文章

UITextField的代理方法:textField:shouldChangeCharactersInRange:replacementString

原文链接:http://www.cnblogs.com/zhanggui/p/6101813.html 这个我在开发的过程中用到的次数最多,因此这里就简单对其进行分析.先看看Command+点击 弹出的内容解释: 它的解释大概意思如下:告诉代理方法指定的text应不应该改变.textfiled会在用户输入内容改变的情况下调用.使用这个方法来验证使用时用户输入的类型.例如,你可以使用这个方法来让用户只是输入数字,而没有其他字符. 它的string参数:用来在指定范围替换的字符.在输入的过程中,这个

UItextfield 基本属性 代理方法

在使用UItextfield时它的基本属性和代理方法都很简单,但有一次我用UItextfield时出现了这种情况,有三个UI textfield,其中第一个点击触发代理方法,其他两个点击处于编辑状态,当时我试了好多方式都没有成功.后来经过查资料和问同事才得以解决.我遇到过这样的问题相信也有很多同行也会遇到,这里我就把它分享给大家. 在头文件中导入: #import "IQKeyboardManager.h" 然后在写入下面两段代码: //设置本视图不使用IQKeyBoard,键盘不使用

UITextfield代理方法传递

The sequence of messages that both text views and text fields send to their delegates is as follows:      1. Just before a text object becomes first responder—textFieldShouldBeginEditing: (text field) and textViewShouldBeginEditing: (text view).The d

设置警告框样式为带有两个文本输入的警告框,用于收集用户收货地址和联系电话。并选择合适的代理方法,当警告框上的两输入框有一个为空时限制“购买”按钮点击。

收集购物信息  iOS项目 倒计时:588 步骤 /.panel-heading 项目需求 设置警告框样式为带有两个文本输入的警告框,用于收集用户收货地址和联系电话.并选择合适的代理方法,当警告框上的两输入框有一个为空时限制“购买”按钮点击. #import "TableViewController.h" @interface TableViewController ()<UIAlertViewDelegate> @property (nonatomic, strong)

iOS textfield代理方法调用的先后顺序(转)

查看原文 今天通过自己的学习把textfield的代理方法全部罗列出来,先后调用顺序做了一下验证. 操作方法是,打开界面-->点击textField-->输入'abc'-->点击'x'清除按钮-->点击键盘'换行'-->点击'完成' log日志: 4 2 4 1 1 1 5 7 6 3 #pragma mark - textField delegate - (BOOL)textField:(UITextField *)textField shouldChangeCharact

ios文本框基本使用,以及所有代理方法的作用

/* UITextField文本输入框 */ UITextField * textField = [[UITextField alloc]initWithFrame:CGRectMake(50, 50, 275, 50)]; //设置边框形式 /* UITextBorderStyleRoundedRect 圆角形式 UITextBorderStyleLine 线条形式 UITextBorderStyleBezel 槽形式 */ textField.borderStyle = UITextBord

textField代理方法

//textField代理方法// 返回no 不能输入文字- (BOOL)textField:(UITextField*)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString*)string // 进入编辑模式- (void)textFieldDidBeginEditing:(UITextField*)textField // 设置中文(locale属性)datePicker.loca

tableview 代理方法详解

typedef NS_ENUM(NSInteger, UITableViewCellAccessoryType) { UITableViewCellAccessoryNone, // 不显示任何图标 UITableViewCellAccessoryDisclosureIndicator, // 跳转指示图标 UITableViewCellAccessoryDetailDisclosureButton, // 内容详情图标和跳转指示图标 UITableViewCellAccessoryCheckm

利用TextFieldDelegate代理方法 – textField:shouldChangeCharactersInRange:replacementString: 限制输入字符

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { if (textField == _workIdTxt) { NSUInteger lengthOfString = string.length; for (NSInteger loopIndex = 0; loopIndex < lengthO