2016-06-20 11 views
0

Ich entwickle eine Anwendung, wo es eine Containeransicht gibt und ich versuche, sie von einem übergeordneten View Controller in einen anderen View Controller zu schieben. Wenn ich versuche, die Navigationsleiste zu drücken, bleibt sie gleich der des übergeordneten Ansichtscontrollers, anstatt in die Navigationsleiste des neu gesteckten Controllers zu wechseln. Hier ist eine Animation dessen, was schief läuft. enter image description here Wie würde ich die Navigationsleiste auf den neuen View-Controller ändern. (Auf einer Seite beachten Sie die Tastatur scheinen muß nicht entweder zu entlassen)Pushing View Controller vom Kind View Controller

Eltern VC

- (UIViewController *)carbonTabSwipeNavigation:(CarbonTabSwipeNavigation *)carbonTabSwipeNavigation 
         viewControllerAtIndex:(NSUInteger)index { 
    if(index == 0){ 
     SearchChildVC *svc = [[SearchChildVC alloc] init]; 
     svc.results = nil; 
     [self searchTop:_searchBar.text]; 
     [[NSNotificationCenter defaultCenter] postNotificationName:@"reload_data" object:self]; 
     return svc; 
    }else if(index == 1){ 
     SearchChildVC *svc = [[SearchChildVC alloc] init]; 
     svc.results = nil; 
     [self searchPeople:_searchBar.text]; 
     [[NSNotificationCenter defaultCenter] postNotificationName:@"reload_data" object:self]; 
     return svc; 
    }else if(index == 2){ 
     SearchChildVC *svc = [[SearchChildVC alloc] init]; 
     svc.results = nil; 
     [self searchOrganizations:_searchBar.text]; 
     [[NSNotificationCenter defaultCenter] postNotificationName:@"reload_data" object:self]; 
     return svc; 
    } 
    return [[SearchChildVC alloc] init]; 
} 

Kind VC

- (void)tableView: (UITableView *) tableView didSelectRowAtIndexPath: (NSIndexPath *) indexPath { 
    [tableView deselectRowAtIndexPath:indexPath animated:YES]; 
    PFObject *data = self.results[indexPath.row]; 
    if (data[@"fullName"]) { 
     // User Cell 
     [self resignFirstResponder]; 
     ForeignProfileVC *fvc = [[ForeignProfileVC alloc] init]; 
     //fvc.userId = ; 
     [self.navigationController pushViewController:fvc animated:YES]; 
    }else{ 
     // Organization Cell 
     [self resignFirstResponder]; 
     OrganizationViewController *ovc = [[OrganizationViewController alloc] init]; 
     ovc.object = (NSDictionary *)data; 
     [self.navigationController pushViewController:ovc animated:YES]; 
    } 
} 

New VC

-(void)setupUI { 
    self.view.backgroundColor = [UIColor whiteColor]; 
    NSString *organizationTitle = [self.object objectForKey:@"Name"]; 
    [self.navigationItem setTitle:organizationTitle]; 
    self.view.backgroundColor = [UIColor whiteColor]; 
    [self.navigationController.navigationBar setTitleTextAttributes: 
    @{NSForegroundColorAttributeName:[UIColor whiteColor], 
     NSFontAttributeName:[UIFont fontWithName:@"OpenSans-Semibold" size:18]}]; 

    UIButton *barButton = [UIButton buttonWithType:UIButtonTypeCustom]; 
    [barButton setTitle:@"" forState:UIControlStateNormal]; 
    [barButton setBackgroundImage:[UIImage imageNamed:@"closeIcon"] forState:UIControlStateNormal]; 
    [barButton addTarget:self action:@selector(didTapClose:) forControlEvents:UIControlEventTouchUpInside]; 
    barButton.frame = CGRectMake(0.0f, 0.0f, 15.0f, 15.0f); 
    UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithCustomView:barButton]; 
    self.navigationItem.leftBarButtonItem = barButtonItem; 

    UIButton *postButton = [UIButton buttonWithType:UIButtonTypeCustom]; 
    [postButton setTitle:@"" forState:UIControlStateNormal]; 
    [postButton setBackgroundImage:[UIImage imageNamed:@"gearIcon"] forState:UIControlStateNormal]; 
    [postButton addTarget:self action:@selector(didTapGear:) forControlEvents:UIControlEventTouchUpInside]; 
    postButton.frame = CGRectMake(0.0f, 0.0f, 18.0f, 18.0f); 
    UIBarButtonItem *postButtonItem = [[UIBarButtonItem alloc] initWithCustomView:postButton]; 
    self.navigationItem.rightBarButtonItem = postButtonItem; 
} 

Antwort

2

wird den gleichen Navigationscontroller wiederverwenden. Sie können entweder presentViewController tun, was einen neuen View-Controller darstellt, oder die Änderung Ihrer Suchleiste selbst übernehmen. Zum Beispiel, in der neuen Ansicht Controller wird so etwas wie Set searchbar versteckt/Set navigationbar zu einem anderen Stil.