Become first responder without animation

前端 未结 3 762
無奈伤痛
無奈伤痛 2021-02-13 18:31

Is there a way for a UITextField to become first responder without the animation of the keyboard? That is, make it such that the keyboard just appears?

Basi

3条回答
  •  耶瑟儿~
    2021-02-13 18:48

    Just set it as the first responder in -viewDidAppear to make the user never notice the field having lost its status.

    -(void)viewWillAppear:(BOOL)animated {
        if ([self isViewLoaded] && self.textField)
            [self.textField becomeFirstResponder];
            [super viewWillAppear:animated];
    }
    

    I've put a short sample project up on dropbox using this code, if you'd like it.

提交回复
热议问题