2013-06-05 6 views
0

어떻게이 코드가 UIView에서 UINavigationBar를 생성하지 않습니까?프로그래밍 방식으로 UINavigationBar 만들기

//create the view 
UIView *view = [[UIView alloc] init]; 
view.backgroundColor = [UIColor whiteColor]; 

//everything for tabbar 
UINavigationBar *navBar = [[UINavigationBar alloc] init]; 

//add the components to the view 
[view addSubview: navBar]; 

//show the view 
self.view = view; 

흰색보기가 표시되지만 NavBar는 표시되지 않습니다. 어떤 도움이 필요합니까? 내가 도대체 ​​뭘 잘못하고있는 겁니까?

+1

'view.frame = CGRectMake (x, y, w, h); navBar.frame = view.bounds; ' –

답변

1

내비게이션 막대의 프레임을 설정하고 볼 수 있도록보기의 하위보기로 추가하십시오. 모든보기가 수퍼 뷰의 좌표계에 위치하도록 프레임을 설정하십시오.

[navBar setFrame:CGRectMake(0,0,CGRectGetWidth(view.frame),44)]; 
[self.view addSubview:navBar]; 

내비게이션 막대, 내가 게시 한 코드에서 볼 수있는 탭 막대가 무엇인지 모릅니다.

+0

죄송합니다. NavBars와 TabBars가 섞여 있습니다. –

+0

'[self.view addSubview : navBar];'제 경우에는 작동하지 않습니다. 'UIView * view'에 추가해야하므로'[view addSubview : navBar]; '를 사용해야합니다. –

+0

코드를 사용하더라도 navBar가 전혀 나타나지 않습니다 ... –

관련 문제