UIViewController的高度设置为460

时间:2012-01-23 06:33:53

标签: iphone objective-c ios ipad

我有一个UIViewController的子类,高度总是460(self.view.frame.size.height)。我没有状态栏,所以我希望它是480?有没有办法可以返回480?

4 个答案:

答案 0 :(得分:4)

你可以这样做:

- (void)viewDidLoad
{
    // View setup

    // Ensure the view will keep filling its parent
    // when the parent view resizes (e.g. device rotation).
    self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
}


- (void)viewWillAppear:(BOOL)animated
{
    // Force to fill the parent once the view is about to be shown.
    self.view.frame = self.view.superview.bounds;
}

如果你要使用XIB,你可以在Interface Builder中设置自动调整模板。

答案 1 :(得分:3)

你可以像这样设置

self.view.frame = CGRectMake(0,0,320,480);

在viewdidLoad或loadView

答案 2 :(得分:1)

转到界面构建器 - >属性Inspector - >模拟指标 - >状态栏 - >没有。 之后,您可以更改视图的高度。

请查看以下链接: how to hide status bar in Iphone application

它可能对你有所帮助..

答案 3 :(得分:0)

如果您使用的是xib,请使用属性隐藏状态栏,否则您可以执行

   [application setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];

在AppDelegate的applicationDidFinishLoading方法中。其他方法是使用info.plist。