1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| //点击编辑按钮 - (IBAction)edit:(UIBarButtonItem *)sender { if ([sender.title isEqualToString:@"取消"]) { //1.改变按钮的文字 sender.title=@"编辑"; //2.允许文本框编辑 _nameField.enabled=NO; _phoneField.enabled=NO; //3.显示保存按钮 _saveBtn.hidden=YES; //4.弹出电话的键盘 [self.view endEditing:YES]; //恢复文本框显示 //给控件赋值 _nameField.text=_contact.name; _phoneField.text=_contact.phone; }else { //1.改变按钮的文字 sender.title=@"取消"; //2.允许文本框编辑 _nameField.enabled=YES; _phoneField.enabled=YES; //3.显示保存按钮 _saveBtn.hidden=NO; //4.弹出电话的键盘 [_phoneField becomeFirstResponder]; } }
|