Iphone 在ios中管理文本字段数的键盘

Iphone 在ios中管理文本字段数的键盘,iphone,keyboard,uitextfield,Iphone,Keyboard,Uitextfield,除了一个病例,我一切都好。当我开始编辑文本字段时,键盘显示:方法正在被调用,但如果我编辑下一个文本字段,在不改变第一个文本字段的情况下,此方法不会被调用 - (void)registerForKeyboardNotifications { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboar

除了一个病例,我一切都好。当我开始编辑文本字段时,键盘显示:方法正在被调用,但如果我编辑下一个文本字段,在不改变第一个文本字段的情况下,此方法不会被调用

- (void)registerForKeyboardNotifications
{
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(keyboardWasShown:)
                                                 name:UIKeyboardDidShowNotification object:nil];

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

}


     -(void)keyboardWasShown:(NSNotification*)aNotification
      {
      NSDictionary* info = [aNotification userInfo];
      CGSize kbSize = [[info objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue].size;

      UIEdgeInsets contentInsets = UIEdgeInsetsMake(0.0, 0.0, kbSize.height, 0.0);
      testScroll.contentInset = contentInsets;
     testScroll.scrollIndicatorInsets = contentInsets;
       CGRect aRect = self.view.bounds;

      CGPoint activepoint= [active.superview convertPoint:active.frame.origin toView:nil];
    if (!CGRectContainsPoint(aRect, activepoint) ) {
        CGPoint scrollPoint = CGPointMake(0.0, active.frame.origin.y+active.frame.size.height-kbSize.height+100);// here active is my particular textfields and i an changing it in begin editing method.
        [testScroll setContentOffset:scrollPoint animated:YES];
    }
这里的问题是,即使我在两个文本字段之间切换,我的scrollview也必须为特定偏移量设置


谢谢。

您的意思是显示了键盘,并且没有调用键盘willbehidden方法吗?我相信,因为如果你只是在文本字段之间切换,键盘从一开始就不会被隐藏。@verbumdei那么,在我的案例中,我如何管理文本字段之间的切换并查看我的编辑