문제

내 응용 프로그램 디자인 중 일부 또는 일부 UIView의 경우 NavigationController의 pushViewController를 따라 새 보기가 상태 표시줄 높이만큼 창 밖으로 이동합니다.결과적으로 이 코드 스텁을 viewDidLoad 메서드에 넣겠습니다.

CGRect  frameAt = [self.view frame];
CGRect  statusBarFrame = [[UIApplication sharedApplication] statusBarFrame];
frameAt.origin.y += statusBarFrame.size.height;
[self.view setFrame: frameAt];

이것이 XCode 및 Interface Builder의 의도라는 것이 나에게는 이해가 되지 않으므로 뷰 디자인 중에 SDK에 근본적으로 잘못된 일을 하고 있는 것으로 의심됩니다.더욱이, 보기를 바꿀 필요가 없는 드문 경우에는 두 디자인 접근 방식의 차이점이 무엇인지 실제로 알 수 없습니다.

또한 대부분의 경우 약간의 사용자 정의를 통해 IB를 사용하여 뷰를 디자인하려고 한다는 점에 유의하세요.

다른 사람이 이 문제를 겪고 그러한 코드 스텁 없이 수정하기 위해 무엇을 해야 하는지 알고 있습니까?

도움이 되었습니까?

해결책

나는 사용했다 Apple의 NavBar 샘플 코드 이 문제를 재현해 보겠습니다.

applicationDidFinishLaunching은 원래 다음과 같이 구현됩니다.

[window addSubview:navigationController.view];
[window makeKeyAndVisible];

이것을 다음과 같이 바꾸면:

UIViewController *shellController = [[UIViewController alloc] initWithNibName:nil bundle:nil];
[shellController.view addSubview:navigationController.view];
[window addSubview:shellController.view];
[window makeKeyAndVisible];

그러면 공백이 나타납니다.

그러나 내가 이렇게만 한다면:

UIView *shell = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[shell addSubview:navigationController.view];
[window addSubview:shell];
[window makeKeyAndVisible];

그러면 모든 것이 정상적으로 보입니다.

그래서 루트 뷰 컨트롤러라면 모든 뷰 컨트롤러가 뷰를 오프셋할 것이라고 생각합니다.그러나 탐색 컨트롤러는 루트 뷰 컨트롤러인지 여부에 관계없이 뷰를 오프셋하기 위해 이 동작을 재정의합니다.따라서 계층 구조의 예상보다 낮은 위치에 내비게이션 컨트롤러가 있기 때문에 공백이 나타나는 것입니다.

다른 팁

The main thing to keep in mind here is that a view controller will set the frame of its view itself. This is because the amount of space available to the view may change during the lifetime of the app, and only the view controller knows how to adjust the view's frame appropriately. Examples of when the amount of space changes include the navigation bar changing height, turning the device from portrait to landscape and the status bar can also increase in height if the user is taking a call. Because of this you should not modify the view's frame yourself.

So, the first thing you need to is is remove all code related to modifiying the view's frame.

Now you need to design your views with the mindset that the frame size could change at any moment. This means setting the autoresizing property of each subview properly. If you do this, then it won't matter if you turn on the simulated navigation and status bars or not; they're just there to help you see what the final result will look like in most cases.

You can set the autoresizing property of each subview in Interface Builder in the Size Inspector (the one with the ruler icon). In the animation, the white box represents the root view of the view controller, the red box represents the currently selected subview. You'll notice that the subview is anchored to the top-left corner of the root view by default. This is fine if the size of the view never changes, but we know that not to be true. If you have subviews that you want to appear at the bottom no-matter-what, then you need to play with the diagram to the left. The way it works is if one of the four lines around the edge is selected, then the distance between that edge of the root view and the edge of the subview is fixed. So if you want a subview to appear at the bottom, you need to make sure the bottom-most line is selected and not the top. The two lines in the middle affect whether the size of the subview changes when the root view change size. So, for example, if you had a table view that you wanted to occupy the entire height of the screen, you would make sure the inner vertical line was selected. This is called the struts and springs model.

If you are adding subviews programatically you need to set the autoresizingMask property on each subview. Here's an explanation.

Hope that helps!

link text

A similar bug is discussed here.

Also is animation set to NO? Try setting it to YES as this solved a similar problem I was facing.

사각형 메소드의 구현이 실제로 누락되었습니다.

메소드 인 링커 오류 메시지에서 볼 수 있습니다.

Rectangle::Rectangle()
Rectangle::GetHeight()
Rectangle::GetWidth()    
.

이 문제를 컴파일하고 Rectangle.o 파일을 링크 해야하는 (또는 .cc, .cxx) 파일이있는 경우

(또는 .cc, .cxx) 파일이있는 경우

여기에 간단한 개요를 묻는 이래로, 다른 파일 이름이 _name이 무엇인지 물어 보았습니다.

  • Rectangle.h 헤더 파일이 클래스 인터페이스를 포함합니다. 일반적 으로이 파일을 읽고 이해하고 이해하는 클래스를 사용 하여이 파일을 읽고 이해하면 충분합니다.
  • Rectangle.cpp 는 구현 또는 소스 파일이며 구현을 포함합니다. 헤더에도 넣을 수 있지만 큰 수업을 위해 헤더 파일이 더 혼잡하고 다른 단점 (컴파일 시간 속도, 덜 캡슐화, ...)
  • Rectangle.o 는 객체 파일입니다. 이것은 컴파일러 이 헤더와 소스 파일에서 나와 링커 에 의해 사용되는 것입니다.
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top