代码之家  ›  专栏  ›  技术社区  ›  Andrew Johnson

如何在3G手机上第一次加速这种视图转换?

  •  2
  • Andrew Johnson  · 技术社区  · 16 年前

    下面的函数是一个名为TitleOverlay的类的方法,它是一个带有textView的透明覆盖。

    该函数通过设置覆盖的alpha动画来显示覆盖,同时使用动画的animationWillStart属性来显示键盘。

    基本上,第一次,有滞后。在随后的所有时间里,键盘和叠加动画并行出现,看起来很不错。

    我能做些什么来解决这个问题?

    - (void) showOverlay {
    
      [[self superview] bringSubviewToFront:self];
    
      NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
      [nc addObserver:self 
             selector:@selector(keyboardWillShow:) 
                name:UIKeyboardWillShowNotification 
              object:nil];
      [nc addObserver:self 
             selector:@selector(keyboardWillHide:) 
                 name:UIKeyboardWillHideNotification 
               object:nil];
    
      [UIView beginAnimations:nil context: nil];
      [UIView setAnimationDuration: .5];
      [UIView setAnimationDelegate:titleField];
      [UIView setAnimationWillStartSelector:@selector(becomeFirstResponder)];
      self.whiteBlock.alpha = 1;
      [UIView commitAnimations];
    
    } 
    
    1 回复  |  直到 16 年前
        1
  •  1
  •   Community Mohan Dere    9 年前

    在iPhone应用程序中首次显示键盘时的延迟是 known issue . 有一个 hack to work around this ,正如该问题所指出的。