Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/42.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 模态解除后ViewController垂直位移20px:仅限iOS4。包括示例代码_Iphone_User Interface_Uinavigationcontroller_Ios4 - Fatal编程技术网

Iphone 模态解除后ViewController垂直位移20px:仅限iOS4。包括示例代码

Iphone 模态解除后ViewController垂直位移20px:仅限iOS4。包括示例代码,iphone,user-interface,uinavigationcontroller,ios4,Iphone,User Interface,Uinavigationcontroller,Ios4,我希望有人能帮忙。。。这个问题已经在这里讨论过了,我尝试过所建议的解决方案,但没有效果 我的问题可以通过以下URL下载的示例项目得到最好的说明: 在示例项目中,我有一个主UIViewController,其中两个按钮用于调用另外两个UIViewController,一个使用presentModalViewController,另一个使用“addSubView”(使用AppDelegate)。单独使用两个按钮和UIViewControllers都可以正常工作 但是,如果首先调用模态viewcon

我希望有人能帮忙。。。这个问题已经在这里讨论过了,我尝试过所建议的解决方案,但没有效果

我的问题可以通过以下URL下载的示例项目得到最好的说明:

在示例项目中,我有一个主
UIViewController
,其中两个按钮用于调用另外两个UIViewController,一个使用
presentModalViewController
,另一个使用“addSubView”(使用AppDelegate)。单独使用两个按钮和
UIViewController
s都可以正常工作

但是,如果首先调用模态viewcontroller,然后将其关闭(使用
dismissModalViewControllerAnimated:YES
),然后显示第二个(
addSubView
UIViewController
,然后显示第二个
UIViewController
中的所有元素和子视图(例如示例中的按钮)垂直向下移动20个像素。位移的发生有一个瞬间的延迟

SDK3.2及以下版本不会出现此问题,只会出现iOS4


任何帮助都将不胜感激,特别是关于上面的示例项目。

添加
[AviewController两个SetWantFullScreenLayout:YES]到您的
-(void)flipToViewControllerTwo
ViewControllerTwo*aViewControllerTwo=[[ViewControllerTwo alloc]initWithNibName:@“ViewControllerTwo”bundle:[NSBundle mainBundle]]之后

要解决此问题,您需要对出现移位的视图控制器执行以下操作:添加帧,然后适当设置此帧的位置。将此帧设置为ViewController的视图

shiftedViewController* ShiftedViewController = [[ShiftedViewController alloc] init ];

CGRect theFrame = [shiftedViewController.view frame];
theFrame.origin.y = 20;
theFrame.origin.x=0;
[shiftedViewController.view setFrame: theFrame];



[self presentModalViewController:shiftedViewController          
                    animated:YES];

谢谢你。这确实有效,但使用该解决方案,您会在viewcontroller显示时出现奇怪的瑕疵-viewcontroller进入视图后,“Disclease”按钮中的文本会稍微移动,而TextView控制器中的文本最初会(暂时)移动在左上角显示为黑点。此问题中链接到的zip文件不再可用。这使得这个问题不再对任何人有用。