calvin sugianto
calvin sugianto

Reputation: 640

BecomeFirstResponder in viewdidload make the views goes up in iOS 10

i have issue with becomeFirstReponder, in iOS 9 , the views keep remain in their spot, but when i upgrade my Xcode to Xcode 8 and compile it with iOS 10, the views move to the top (out of screen) when the keyboard begins to appear.

- (void)viewDidLoad {
[super viewDidLoad];

[self.usernameTextField becomeFirstResponder];
}

Is there any other solution to make the keyboard is appear without moving other element to the top?

Upvotes: 0

Views: 375

Answers (1)

Ashish Kakkad
Ashish Kakkad

Reputation: 23882

I have also faced this issue.

Just use view's layoutIfNeeded before becomeFirstResponder

[self.view layoutIfNeeded];

Try like this :

- (void)viewDidLoad {

    [super viewDidLoad];
    [self.view layoutIfNeeded];
    [self.usernameTextField becomeFirstResponder];

}

Hope it will help you.

Upvotes: 1

Related Questions