For iOS6 only, the first subview is misaligned on the nesting of the UINavigationController.

Asked 2 years ago, Updated 2 years ago, 116 views

(editing after being pointed out)

We are currently developing iOS using the UINavigationController. It's a bit tricky to use, but it's in the view normally generated by the UINavigationController. I'm also trying to display something with a structure called "UINavigationController > UIViewController > UITableView".

Specifically, for the view displayed in the UINavigationController, click When you press the button on the UINavigationBar, you do the following:

stI don't use any storyboard.

The intent of the design is to simply create a custom UIView so that it can be used with addSubview.

The purpose of a custom view is to overlay the currently displayed view. I would like to see a pop-up view that is a little smaller from the entire screen.

iOS7 and iOS8 show no problems, but for some reason only iOS6 is available. The UITableView above has shifted to 20px (probably Status bar minutes). After the view appears (for example, viewWillAppear), the change of position does not change for some reason. (Specifically, the UITableView is pulled and updated, with the UINavigationBar slightly overlapping at the top.)

What can be considered to be the difference in behavior when nested in this way? (Personally, I think the behavior of the UINavigationController may automatically be corrected in consideration of the status bar.)

Sorry for the abstract question.

[Additional note] The implementation issue has been resolved. (UINavigationBar side shifted upside down) However, it has not been improved in nature, so it feels like it has been consistent in appearance.

ios objective-c ios6 uinavigationcontroller

2022-09-30 14:39

1 Answers

I can't reproduce the code, so I don't know if it really works, but
Before you addSubView to your parent's UIViewController, how do you invoke addChildViewController as follows?

 [selfaddChildViewController:childVC];
childVC didMoveToParentViewController:self;
mainView addSubview:childVC.view;

There was a similar question in the English version, and there was a comment saying that calling addChildViewController fixed it.

As for what the addChildViewController is doing, I think this question is easy to understand.

According to the correct answer, the addChildViewController does not have much to do, and declaring itself a child of a UIViewController will inform you of various events.

// If possible, it would be easier for you to add a code to the github etc.


2022-09-30 14:39

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.