2010-11-30 82 views
0

这里有什么问题?NSInvalidArgumentException原因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; 

    } 
} 

的异常火灾试图辞职第一响应时(即当我点击键盘上的“完成”按钮),但键盘仍然显示,并没有进入keyboardWasHidden的是,这是UIKeyboardWillHideNotification的接收器

回答

0

我是通过下面的代码行听通知

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

所以这是一个小错误, 的选择“keyboardWasHidden ::”应该是“keyboardWasHidden:”

希望对任何人都有用。

相关问题