2010-09-05 61 views
0

我希望有人可以帮助...这个问题已经在这里讨论,我已经尝试了解决方案建议,但无济于事。模式关闭后,ViewController垂直移动20px:iOS4 Only。示例代码包括

我的问题是使用示例项目,可以从该URL下载最好的说明:

http://www.hitsalive.com/tmp/VCTest.zip

在这个例子中的项目,我都习惯叫另外两个UIViewControllers主UIViewController有两个按钮 - 一个使用presentModalViewController,另一个使用“addSubView”(使用AppDelegate)。单独的按钮和UIViewController工作正常。

但是,如果我首先调用模态的ViewController,然后关闭它(使用dismissModalViewControllerAnimated: YES),然后显示所述第二(addSubViewUIViewController,那么所有的元素和子视图在所述第二UIViewController(诸如本例中的按钮)得到垂直向下移动20个像素。流离失所发生在短暂的延迟。

此问题在SDK 3.2及以下版本中不会发生 - 只是iOS4。

任何帮助将不胜感激,尤其是参考上面的示例项目。

+0

链接到此问题的zip文件不再可用。这使得这个问题不再适用于其他任何人。 – Keith 2011-09-02 20:11:47

回答

1

ViewControllerTwo *aViewControllerTwo = [[ViewControllerTwo alloc] initWithNibName:@"ViewControllerTwo" bundle:[NSBundle mainBundle]];

+0

感谢GameBit。这种方法确实有效,但是通过该解决方案,您可以像viewcontroller显示一样获得奇怪的构件 - 在Viewcontroller进入视图后,“Dismiss”按钮中的文本略有移动,并且TextView控制器中的文本最初(暂时)显示为黑点在左上角。 – declan 2010-10-05 19:46:38

1

后添加[aViewControllerTwo setWantsFullScreenLayout:YES];- (void)flipToViewControllerTwo为了解决这个问题,你需要做的与出现转向视图控制器如下:添加一个框架,然后适当地设置该框架的位置。将此框架设置为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];