Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 在纵向和横向选项卡视图中选择文本字段时,如何从键盘向上移动?_Iphone_Objective C - Fatal编程技术网

Iphone 在纵向和横向选项卡视图中选择文本字段时,如何从键盘向上移动?

Iphone 在纵向和横向选项卡视图中选择文本字段时,如何从键盘向上移动?,iphone,objective-c,Iphone,Objective C,我在表视图中有8个文本字段。我需要以纵向和横向模式将数据输入该文本字段。某些文本字段位于键盘的背面。我无法在该文本字段中输入数据 在willShowKeyBoard通知的帮助下,我已经在纵向模式下完成了,并且工作正常。但是,同样的事情我已经应用到横向模式,但工作不正常。如何向上移动表格视图以在文本字段中输入数据 (无效)键盘将显示:(NSNotification*)notif { } -(无效)setViewMovedUp:(BOOL)movedUp { [UIView beginAnim

我在表视图中有8个文本字段。我需要以纵向和横向模式将数据输入该文本字段。某些文本字段位于键盘的背面。我无法在该文本字段中输入数据

在willShowKeyBoard通知的帮助下,我已经在纵向模式下完成了,并且工作正常。但是,同样的事情我已经应用到横向模式,但工作不正常。如何向上移动表格视图以在文本字段中输入数据

  • (无效)键盘将显示:(NSNotification*)notif {

}

-(无效)setViewMovedUp:(BOOL)movedUp { [UIView beginAnimations:nil上下文:NULL]; [UIView setAnimationDuration:0.5];//如果要向上滑动视图 CGRect=myView.frame; if(movedUp) {
rect.origin.y=rect.origin.y-键盘1的kOFFSET_; rect.size.height=rect.size.height+kOFFSET_表示键盘1; } 其他的 { rect.origin.y=rect.origin.y+kOFFSET_表示键盘1; rect.size.height=rect.size.height-kOFFSET_表示键盘1; }


}

我不知道您是否已经在使用此功能,但请看这里:

它解释了它是如何工作的,并且做得很好。它也应该在lanscape模式下工作,因为它可以查看键盘的像素数并向上推送内容


向Tim致以最诚挚的问候您应该使用UIScrollView来完成此操作,然后您可以上下移动内容

if ([NameField isFirstResponder] && myView.frame.origin.y >= 0)
{       

}
else if([credentialField isFirstResponder] && myView.frame.origin.y >=0)
{

}
else if([specialityField isFirstResponder] && myView.frame.origin.y >=0)
{

}
else if([streetField isFirstResponder] && myView.frame.origin.y >=0)
{
    [self setViewMovedUp:YES];
}
else if([cityField isFirstResponder] && myView.frame.origin.y >=0)
{
    [self setViewMovedUp:YES];
}
else if([stateField isFirstResponder] && myView.frame.origin.y >=0)
{
    [self setViewMovedUp:YES];
}
else if([zipcodeField isFirstResponder] && myView.frame.origin.y >=0)
{
    [self setViewMovedUp:YES];
}
myView.frame=rect;
[UIView commitAnimations];