Search code examples
iosobjective-cuiviewanimationios-keyboard-extension

iOS Keyboard Making View Disappear


I am having a bit of an issue here. I have my main view for my application, for different windows. I have put them off the view sight and they're animated to move into view when they are required, I have never had an issue with this before until I decided to create a text field. When I click the button to bring the view into show it appears, but when I click the text field to type and the keyboard loads the view disappears, but if I click the button to bring the view back the text field will be entered and ready to type. Anyone got any solutions? I am attaching the code below of the way the view is appearing.

Thanks,

CurtisB

- (IBAction)login:(id)sender {

    sidebutton = @"0";
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.0];
    [self.blackhide setFrame:CGRectMake(self.blackhide.frame.origin.x -750, self.blackhide.frame.origin.y, self.blackhide.frame.size.width, self.blackhide.frame.size.height)];
    [UIView setAnimationDuration:0.5];
    [self.button2 setFrame:CGRectMake(self.button2.frame.origin.x - 300, self.button2.frame.origin.y, self.button2.frame.size.width, self.button2.frame.size.height)];
    [self.mainview setFrame:CGRectMake(self.mainview.frame.origin.x - 300, self.mainview.frame.origin.y, self.mainview.frame.size.width, self.mainview.frame.size.height)];
    [self.sidebarview setFrame:CGRectMake(self.sidebarview.frame.origin.x - 376, self.sidebarview.frame.origin.y, self.sidebarview.frame.size.width, self.sidebarview.frame.size.height)];
    [UIView setAnimationDuration:0.0];
    [self.loginview setFrame:CGRectMake(self.loginview.frame.origin.x + 376, self.loginview.frame.origin.y, self.loginview.frame.size.width, self.loginview.frame.size.height)];  
}

Solution

  • Try to bring the subview you want at the top to front by using following code:

    [parentView bringSubviewToFront:childView];
    

    For example, if you want to show VIEW_A, do that code whenever you are un-hiding that view. If still you get that issue, put that code when keyboard appears i.e. in UITextfield delegate method..

    Add comment if you are still stuck..