在.h文件当中UIViewController后面加上<UITextFieldDelegat>
在.m文件当中加入实现部分 self.username.delegate=self;self.Password.delegate=self;