2010-09-05 62 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];