我这里有点问题。对于不同的窗口,我有我的应用程序的主视图。我已经将它们从视线中移开,并在需要时将它们动画化以进入视野,在我决定创建文本字段之前,我从来没有遇到过这个问题。当我单击按钮将 View 带入显示时,它会出现,但是当我单击文本字段进行键入并且键盘加载时, View 消失,但是如果我单击按钮将 View 带回显示,文本字段将被输入并准备就绪输入。有人有任何解决方案吗?我在下面附上 View 显示方式的代码。
谢谢,
柯蒂斯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
,请在取消隐藏该 View 时执行该代码。如果您仍然遇到该问题,请在出现键盘时输入该代码,即在 UITextfield
委托(delegate)方法中..
如果您仍然卡住,请添加评论..
关于iOS 键盘使 View 消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34333463/