뷰의 맨 아래에 UIToolbar가 있습니다. 사용자가 iPad에있을 때 네비게이션 컨트롤러의 오른쪽에 툴바를 추가하고 싶습니다.UIToolbar를 UINavigationItem 오류로 추가하십시오.
- (void)viewDidLoad{
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
UIBarButtonItem *toolBarItem = [[UIBarButtonItem alloc]initWithCustomView:toolBar];
self.navigationItem.rightBarButtonItem = toolBarItem;
}
[super viewDidLoad];
}
그러나 오류가있는 응용 프로그램이 충돌 :
는이 코드를 추가Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Auto Layout still required after executing -layoutSubviews. UINavigationBar's implementation of -layoutSubviews needs to call super.'
이 문제가 왜 이전에 사용이 방법을 볼 수 있기 때문에 내가 모르는 . 그건 그렇고, 툴바 항목은 NSArray 버튼을 사용하는 대신 인터페이스 빌더에 추가됩니다, 그 차이를 만들 수 있을까요?
감사합니다.
일반적으로 UIBarButtonItem은 어디에서 선언합니까? – Dustin
plz는 toolBar alloc 및 init 코드를 보여줍니다. –
그리고 [super viewDidLoad]가 있습니까? viewDidLoad 메서드에서? –