2012-05-03 1 views

답변

13

, 이것은 당신이 원하는 것입니다. 다음 코드 "CustomViewController"라는 새로운 클래스를 만들고 붙여 넣습니다

인터페이스를

#import <UIKit/UIKit.h> 

@interface CustomViewController : UIViewController 

- (id)initWithViewController:(UIViewController*)viewController bottomView:(UIView*)bottomView; 

@end 

구현 :

UIView *myBottomView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 100)]; 
myBottomView.backgroundColor = [UIColor redColor]; 

CustomViewController *customViewController = [[CustomViewController alloc] initWithViewController:<yourNavigationController> bottomView:myView]; 
:

#import "CustomViewController.h" 

@implementation CustomViewController 

- (id)initWithViewController:(UIViewController*)viewController bottomView:(UIView*)bottomView 
{ 
    self = [super init]; 
    if (self) { 

     // Set up view size for navigationController; use full bounds minus 60pt at the bottom 
     CGRect navigationControllerFrame = self.view.bounds; 
     navigationControllerFrame.size.height -= 60; 
     viewController.view.frame = navigationControllerFrame; 

     // Set up view size for bottomView 
     CGRect bottomViewFrame = CGRectMake(0, self.view.bounds.size.height-60, self.view.bounds.size.width, 60); 
     bottomView.frame = bottomViewFrame; 

     // Enable autoresizing for both the navigationController and the bottomView 
     viewController.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 
     bottomView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin; 

     // Add views as subviews to the current view 
     [self.view addSubview:viewController.view]; 
     [self.view addSubview:bottomView]; 
    } 
    return self; 
} 

@end 
이제

이 CustomViewController를 사용하는

+0

감사합니다. 우 !!! 이게 정확히 내가 원하는 것입니다 –

+0

오, ,, 내가 구현하는 동안 문제가, 내가 구현 된 소스 코드를 얻을 수 있습니까? 너무 좋아질 것입니다 : D –

+0

@PangHoMing UINavigationController 설정 방법에 대해 더 자세히 알려면 추가 코드/정보를 제공 할 수 있습니다. –

0

이 정적 하위 뷰를 내비게이션 컨트롤러보기 (일반적으로 UIWindow 근처의 수평)와 같은 레벨에 추가하지 않는 이유는 무엇입니까? 그냥 거기에 추가하고 가장 많이 만듭니다. 이것에

UIView below UINavigationController or below TabBar

당신은 수를 UINavigationController가를 둘러싸는 사용자 정의의 UIViewController를 만들어 : 만약 내가 제대로 이해하고