这是怎么回事?
- (IBAction)textFieldDidEndEditing:(id)sender
{
if(!_isEditing )
return;
UITextField* textField = (UITextField*)sender;
NSString* newValue = [textField text];
UITableViewCell* cell = [self GetCellFromTextField:textField];
NSString* fieldName =[(UILabel*)[self GetLabelHeaderFromCell:cell] text];
NSIndexPath* indexPath= [self GetIndexPathForCell:cell];
[PersonalSection SetFieldValue:newValue AndFieldName:fieldName UsingIndexPath:indexPath AndPersonalInformation:self.personalInfoInUse];
_trackingEditTextField=nil;
[fieldName release];
_isEditing = FALSE;
}
- (IBAction)textFieldDidBeginEditing:(id)sender
{
_trackingEditTextField=(UITextField*)sender;
}
-(IBAction)textFieldDidChange
{
_isEditing=YES;
self.navigationItem.rightBarButtonItem = saveButton;
self.navigationItem.leftBarButtonItem = cancelButton;
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField {
[_trackingEditTextField resignFirstResponder];
return NO;
}
-(void)KeyboardDidShow:(NSNotification*) notification
{
if ( keyboardShown )
return;
CGRect frame = tableView.frame;
frame.size.height -= 165;
tableView.frame = frame;
[tableView scrollToRowAtIndexPath:[self GetIndexPathForTextView:_trackingEditTextField] atScrollPosition:0 animated:YES];
keyboardShown = YES;
}
- (void)keyboardWasHidden:(NSNotification *)notification {
if ( keyboardShown ) {
CGRect frame = tableView.frame;
frame.size.height += 165;
tableView.frame = frame;
keyboardShown = NO;
}
}当尝试退出first responder时(即,当我单击键盘上的'done‘按钮时),但键盘仍在显示,并且尚未输入UIKeyboardWillHideNotification的接收方keyboardWasHidden,则会触发异常
发布于 2010-12-01 22:48:26
我通过以下代码行监听通知
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(keyboardWasHidden::) name:UIKeyboardWillHideNotification object:nil];所以这是一个小错误,选择器"keyboardWasHidden::“应该是"keyboardWasHidden:”
希望它对任何人都有用。
https://stackoverflow.com/questions/4314940
复制相似问题