IOS学习之UITextfield-创新互联

1. UITextFieldDelegate的代理

专注于为中小企业提供网站设计制作、网站建设服务,电脑端+手机端+微信端的三站合一,更高效的管理,为中小企业塔河免费做网站提供优质的服务。我们立足成都,凝聚了一批互联网行业人才,有力地推动了成百上千家企业的稳健成长,帮助中小企业通过网站建设实现规模扩充和转变。

开始输入的监听:

    // return NO to disallow editing.

    - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField;

输入结束的监听:

   - (void)textFieldDidEndEditing:(UITextField *)textField;

等等。在这些方法中,添加相应的操作。

2.获取UITextField输入内容

[self.accountText addTarget:self action:@selector(input:) forControlEvents:UIControlEventEditingChanged];

- (void) input:(UITextField*)textField {

}

3.监听键盘事件的通知

 [[NSNotificationCenter defaultCenter] addObserver:self

                       selector:@selector(keyboardWillShow:)

                         name:UIKeyboardWillShowNotification

                        object:nil];

  [[NSNotificationCenter defaultCenter] addObserver:self

                       selector:@selector(keyboardShow:)

                         name:UIKeyboardDidShowNotification

                        object:nil];

  [[NSNotificationCenter defaultCenter] addObserver:self

                       selector:@selector(keyboardWillHide:)

                         name:UIKeyboardWillHideNotification

                        object:nil];

  [[NSNotificationCenter defaultCenter] addObserver:self

                       selector:@selector(keyboardHide:)

                         name:UIKeyboardDidHideNotification

                        object:nil];

- (void)keyboardWillShow:(NSNotification *)notif {

}

- (void)keyboardShow:(NSNotification *)notif {

}

- (void)keyboardWillHide:(NSNotification *)notif {

}

- (void)keyboardHide:(NSNotification *)notif {

}

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


文章标题:IOS学习之UITextfield-创新互联
网页地址:http://pwwzsj.com/article/shieg.html