2011-03-18 4 views
0

특정보기 컨트롤러에 도구 모음 단추가 있고 다른보기 컨트롤러에서 사라질 필요가 있습니다. 어떻게 할 수 있어요 !!하나의보기 컨트롤러에서 도구 모음 단추뿐만 아니라 다른 사람에게 표시

 
- (void)viewWillDisappear:(BOOL)animated {} 
- (void)viewDidDisappear:(BOOL)animated {} 

: 내가 작업 할 수

 

- (void)viewWillAppear:(BOOL)animated { 
    [super viewWillAppear:animated]; 
    //Initialize the toolbar 
    toolbar = [[UIToolbar alloc] init]; 
    toolbar.barStyle = UIBarStyleDefault; 
    //Set the toolbar to fit the width of the app. 
    [toolbar sizeToFit]; 
    //Caclulate the height of the toolbar 
    CGFloat toolbarHeight = [toolbar frame].size.height; 
    //Get the bounds of the parent view 
    CGRect rootViewBounds = self.parentViewController.view.bounds; 
    //Get the height of the parent view. 
    CGFloat rootViewHeight = CGRectGetHeight(rootViewBounds); 
    //Get the width of the parent view, 
    CGFloat rootViewWidth = CGRectGetWidth(rootViewBounds); 
    //Create a rectangle for the toolbar 
    CGRect rectArea = CGRectMake(0, rootViewHeight - toolbarHeight, rootViewWidth, toolbarHeight); 
    //Reposition and resize the receiver 
    [toolbar setFrame:rectArea]; 
    //Create a button 
    UIBarButtonItem *infoButton = [[UIBarButtonItem alloc] 
            initWithTitle:@"Info" style:UIBarButtonItemStyleBordered target:self action:@selector(info_clicked:)]; 
    [toolbar setItems:[NSArray arrayWithObjects:infoButton,nil]]; 
     //Add the toolbar as a subview to the navigation controller. 
    [self.navigationController.view addSubview:toolbar]; 
    //Reload the table view 
    [self.tableView reloadData]; 

} 

- (void) info_clicked:(id)sender { 
//Initialize the Info View Controller 
    if(ivControllerToolbar == nil) 
     ivControllerToolbar = [[InfoViewController alloc] initWithNibName:@"InfoView" bundle:[NSBundle mainBundle]]; 
    ivControllerToolbar.isViewPushed = NO; 
    //Initialize the navigation controller with the info view controller 
    if(infoNavController == nil) 
     infoNavController = [[UINavigationController alloc] initWithRootViewController:ivControllerToolbar]; 
    //Present the navigation controller. 
    [self.navigationController presentModalViewController:infoNavController animated:YES]; 
} 

: 여기 내 코드는? 그리고 어떻게 알 수 있습니까?

답변

0

viewWillAppear:에 툴바를 만드는 이유를 알 수 없습니다. viewDidLoad 또는 loadView에보기 계층 구조를 만드는 것이 좋습니다 (보기를 만드는 데 xib를 사용하지 않는 경우)