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

前端 未结 6 877
遇见更好的自我
遇见更好的自我 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:39

    Try following:

     Toolbar.autoresizingMask = UIViewAutoresizingFlexibleTopMargin;
    
    0 讨论(0)
  • 2021-02-13 04:44

    My problem was solved unmarking the check "Adjust Scroll View Insets" in the View Controller (using Storyboards).

    0 讨论(0)
  • 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];
    
    0 讨论(0)
  • 2021-02-13 04:57

    Add following code its work for me for same issue, may be its help you

    /* ios 7 Change */
        if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7)
        {
            self.edgesForExtendedLayout = UIRectEdgeNone;
            self.automaticallyAdjustsScrollViewInsets = NO;
        }
    
    0 讨论(0)
  • 2021-02-13 05:00

    I think the problem is due to incorrect automatic set of content insets of the scrollview.

    Try the following. In your loadView, set self.automaticallyAdjustsScrollViewInsets to NO (only if NSFoundationVersionNumber > NSFoundationVersionNumber_iOS_6_1). Now, set the contentInset and scrollIndicatorInsets to the correct values depending on OS version:

    scrollview.contentInset = scrollview.scrollIndicatorInsets = UIEdgeInsetMake(NSFoundationVersionNumber <= NSFoundationVersionNumber_iOS_6_1 ? 0 : 64, 0, 0, 0);
    
    0 讨论(0)
  • 2021-02-13 05:01

    Does this only happen on iOS 7?

    Give this a try:

    self.navigationController.navigationBar.translucent = NO;
    
    0 讨论(0)
提交回复
热议问题