iOS7 View moves under status/nav bars when loadView called again

前端 未结 6 861
遇见更好的自我
遇见更好的自我 2021-02-13 03:57

I have a View Controller that creates its view programatically through the loadView method. The purpose of the view is to display a data models contents. When the v

6条回答
  •  孤城傲影
    2021-02-13 04:46

    try this

    CGRect frame = CGRectMake(0, StatusBarHeight, [Constants ScreenWidth], [Constants ScreenHeight] - StatusBarHeight - ToolbarHeight);
    self.view = [[UIView alloc] initWithFrame:frame];
    self.view.autoresizingMask = UIViewAutoresizingFlexibleHeight;
    self.view.autoresizesSubviews = YES;
    self.view.backgroundColor = [Constants categoriesScreenBackgroundColor];
    
    CGRect scrollFrame = CGRectMake(0, StatusBarHeight, [Constants ScreenWidth], [Constants ScreenHeight] - StatusBarHeight - ToolbarHeight - ToolbarHeight);
    UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:scrollFrame];
    scrollView.autoresizingMask = UIViewAutoresizingFlexibleHeight |
            UIViewAutoresizingFlexibleBottomMargin |
            UIViewAutoresizingFlexibleTopMargin;
    [self.view addSubview:scrollView];
    

提交回复
热议问题