簡體   English   中英

在iOS 6中,按下View Controller可以將其視圖向上移動20個像素嗎?

[英]Pushing a View Controller moves its view up by 20 pixels in iOS 6?

我有一個導航控制器,按以下方式在其上添加UIViewController

UINavigationController * navController = [[UINavigationController alloc] initWithRootViewController:self.homeViewController];

_centerViewNavigaionController = navController;

if (bIsDeviceOSVersion7) {
    _centerViewNavigaionController.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);
}
else
{
 _centerViewNavigaionController.view.frame = CGRectMake(0, -20, self.view.frame.size.width, self.view.frame.size.height+20);
}

[self.view addSubview:navController.view];
[self addChildViewController:navController];

它在iOS 7中工作正常,但在iOS6中-HomeViewController(即此導航控制器的RootViewController)加載良好。 但是,當我將一個新的View Controller推到HomeViewController即RootViewController時,新的視圖幀僅在第一時間向上移動了20像素。 下次按下它時,它可以正常工作。 我查找了堆棧溢出,但無法解決此問題。 我怎樣才能解決這個問題?

而不是這樣做

_centerViewNavigaionController.view.frame = CGRectMake(0,-20,self.view.frame.size.width,self.view.frame.size.height + 20);

您只需通過Interface Builder為viewcontroller對象下的一個或多個即時視圖設置delta屬性。 否則,您必須使用“自動布局”來避免此類情況。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM