Content pushed down in a UIPageViewController with UINavigationController

后端 未结 15 631
暗喜
暗喜 2020-12-12 18:05

UPDATE 2

I\'ve been running and testing my app in the iOS Simulator using a 4-inch device. If I run using a 3.5-inch device the label doesn\'t jump.

相关标签:
15条回答
  • 2020-12-12 18:39

    As stated by "Bo:": Putting self.edgesForExtendedLayout = UIRectEdgeNone; in the viewDidLoad of MyPageViewController solved the problem. – Bo

    0 讨论(0)
  • 2020-12-12 18:40

    Swift's version of djibouti33's answer (excluding the line that is not part of the problem resolution)

    Swift 3.0

    override func viewDidLoad() {
        super.viewDidLoad()
        self.automaticallyAdjustsScrollViewInsets = false
    }
    
    0 讨论(0)
  • 2020-12-12 18:45

    this is my first time posting on stack overflow, but I have searching for a solution to this problem for over a week now.

    Here is a solution I came up with, I hope this works for anyone else with the same issue.

    I'm not sure how you are initializing your frame for your detail view controller, but I am going to assume you might use: self.view.frame.size.height;

    try using: self.view.frame.size.height -= self.navigationController.navigationBar.bounds.size.height;

    Hope this helps

    0 讨论(0)
  • 2020-12-12 18:46

    I have the same problem. I solve it by putting setViewControllers for the first page in UIPageViewController's viewDidLoad instead of setting it when I make a instance of UIPageViewController. Also, I need to set automaticallyAdjustsScrollViewInsets to NO.

    0 讨论(0)
  • 2020-12-12 18:47

    So I'm adding another answer after further development and I finally think I figured out what's going on. Seems as though in iOS7, UIPageViewController has its own UIScrollView. Because of this, you have to set automaticallyAdjustsScrollViewInsets to false. Here's my viewDidLoad now:

    - (void)viewDidLoad
    {
        [super viewDidLoad];
    
        self.automaticallyAdjustsScrollViewInsets = false;
    
        DetailViewController *detail = [[DetailViewController alloc] init];
        [self setViewControllers:@[detail]
                       direction:UIPageViewControllerNavigationDirectionForward
                        animated:false
                      completion:nil];
    }
    

    No need to put anything in viewWillLayoutSubviews (as one of my previous answers suggested).

    0 讨论(0)
  • 2020-12-12 18:47

    None of above worked for me

    Here I found the solution

    var pageMenu : CAPSPageMenu?
    

    Instead of adding like this

    self.view.addSubview(pageMenu!.view)
    

    Add your CAPSPageMenu like below

    addChildViewController(pageMenu!) 
    self.view.addSubview(pageMenu!.view) 
    pageMenu!.didMove(toParentViewController: self)
    

    Reference: iOS Swift : SlidingMenuView wrong Position after presenting imagePicker

    Happy Coding!

    0 讨论(0)
提交回复
热议问题