【问题标题】:rooViewController leaving gap at the bottom of the screenrooViewController 在屏幕底部留下空隙
【发布时间】:2013-02-06 15:00:47
【问题描述】:

Mt rootViewController(即第一个视图控制器)没有占据全屏,而其他 VC 则占据了(见截图)。在 IB 中,它们看起来相同。我正在使用 iOS 6 / iOS 5.1 模拟器。

我的 AppDelegate 方法看起来很无辜。有什么建议吗?

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // hide status bar
    [UIApplication sharedApplication].statusBarHidden = YES;
    _window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // allocate the root view controller
    _window.rootViewController = [[LMHomeViewController alloc] init];
    // add a navigation controller
    [LMNavigationController initSharedInstanceWithRootViewController:self.window.rootViewController];
    [_window addSubview:LMNavigationController.sharedInstance.view];
    // show the window
    [_window makeKeyAndVisible];
    return YES;
}

【问题讨论】:

    标签: iphone uiviewcontroller simulator


    【解决方案1】:

    隐藏 LMHomeViewController xib 文件中的状态栏。

    在您的 info.plist 中,将“状态栏最初隐藏”设置为 YES。

    我认为问题在于您的 LMHomeViewController 被“渲染为带有状态栏”,然后您将此视图添加到没有状态栏的视图中,因此存在 20 px 的间隙。

    【讨论】:

      【解决方案2】:

      //在appDelegate.h文件中

      @property (strong, nonatomic) UIWindow *window;

      @property(强,非原子)LMHomeViewController *homeController;

      //在appDelegate.m文件中

      self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];

      self.homeController = [[[LMHomeViewController alloc] initWithNibName:@"LMHomeViewController" bundle:nil] autorelease];

      self.window.rootViewController = self.viewController;

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-11-01
        • 2014-11-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多