iOS 键盘使视图消失

iOS Keyboard Making View Disappear

我这里有点问题。对于不同的 windows,我有我的应用程序的主视图。我已经将它们从视线中移开,并在需要时将它们动画化以进入视野,在我决定创建文本字段之前,我从来没有遇到过这个问题。当我单击按钮将视图带入显示时,它会出现,但是当我单击文本字段进行键入并且键盘加载时,视图消失,但是如果我单击按钮将视图带回显示,文本字段将被输入并准备就绪输入。有人有任何解决方案吗?我在下面附上视图显示方式的代码。

谢谢,

柯蒂斯 B

- (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)];  
}

尝试使用以下代码将您想要的 subview 置于最前面:

[parentView bringSubviewToFront:childView];

例如,如果您想显示 VIEW_A,请在取消隐藏该视图时执行该代码。如果您仍然遇到该问题,请在出现键盘时输入该代码,即在 UITextfield 委托方法中..

如果您仍然卡住,请添加评论..