2010-11-30 13 views
0

Quel est le problème ici?NSInvalidArgumentException raison keyboardWasHidden?

- (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; 

    } 
} 

Les feux d'exception lors de la tentative de démissionner premier intervenant (lorsque je clique sur le « fait » sur le clavier), mais le clavier est toujours à l'affiche et il n'a pas entrer encore keyboardWasHidden, qui est le récepteur de UIKeyboardWillHideNotification

Répondre

0

J'écoutais la notification par la ligne de code suivante

[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(keyboardWasHidden::) name:UIKeyboardWillHideNotification object:nil]; 

il était une petite erreur, le sélecteur « keyboardWasHidden :: » aurait dû être « keyboardWasHidden: »

espérons que c'est utile pour tout le monde.