2013-05-27 30 views
1

我有推着視圖 - 控制。這一個問題,就是我所做的:Probem與UINavigationController的

- (void)addAction:(id)sender 
{ 
    uipickerForContract *addViewController = [[uipickerForContract alloc] initWithNibName:@"uipickerForContract" bundle:nil]; 
    addViewController.delegate = self; 

    addViewController.modalPresentationStyle = UIModalPresentationFormSheet; 
    addViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; 

    [self presentModalViewController:addViewController animated:YES]; 

    addViewController.view.superview.frame = CGRectMake(50, 740, 695, 245); 


} 

此添加視圖 - 控制:一個按鈕的CLIK我用我的代碼,它工作正常添加模式視圖包含一個完成按鈕,我想,以用於導航到其他視圖 - 控制:所以我使用的代碼,但它不工作,它只是駁回addeview:

donebutton{ 

    nextview*s = [[nextview alloc]initWithNibName:@"nextview" bundle:nil]; 
    s.view.frame = CGRectMake(10, 20, 745, 755); 
    //nextview contains the object that I want to pass :object 
     s.object= self; 
     UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:self]; 
    [self dismissModalViewControllerAnimated:YES]; 
     [self.navigationController pushViewController:s animated:YES]; 
     NSLog(@"self.nav%@",self.navigationController); 
    } 

任何想法,請幫助我

+0

一旦你調用[self dismissModalViewControllerAnimated:YES];控制返回推視圖將不會被調用。檢查nslog self.nav%@是否正在打印 – Durgaprasad

+0

是的,nslog self.nav%@正在打印 –

+0

這一行UINavigationController * nav = [[UINavigationController alloc] initWithRootViewController:self]; '是無用的instatiation。你能更精確地說明:你的代碼示例都屬於同一個類(viewController),還是'self'在這裏表示不同的東西? – Vinzzz

回答

-1

你需要把解僱和明年推這樣的事情

之前之間有一些延遲:

nextview*s = [[nextview alloc]initWithNibName:@"nextview" bundle:nil]; 
s.view.frame = CGRectMake(10, 20, 745, 755); 
//nextview contains the object that I want to pass :object 
    s.object= self; 
    UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:self]; 
[self dismissModalViewControllerAnimated:YES]; 
    [self.navigationController pushViewController:s animated:YES]; 
    NSLog(@"self.nav%@",self.navigationController); 

後:視圖控制器

[self dismissModalViewControllerAnimated:YES]; 
[self performSelector:@selector(pushNextView) withObject:nil afterDelaye:0.40]; 

- (void) pushNextView { 
    nextview*s = [[nextview alloc]initWithNibName:@"nextview" bundle:nil]; 
    s.view.frame = CGRectMake(10, 20, 745, 755); 
    //nextview contains the object that I want to pass :object 
     s.object= self; 
     UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:self]; 

     [self.navigationController pushViewController:s animated:YES]; 
     NSLog(@"self.nav%@",self.navigationController); 
} 
+0

我不同意,我有一個模式控制器中的動作後,UINavigationController推動viewController,和'[自我dismissViewController動畫之間不需要延遲。 ..]'和'[self.navigationController pushViewController:...]' – Vinzzz

+0

[self dismissModalViewControllerAnimated:YES]; dispatch_async(dispatch_get_main_queue(),^ { 的UINavigationController * NAV = [[UINavigationController的頁頭] initWithRootViewController:自]; 新思維* S = [[新思維的alloc] initWithNibName:@ 「新思維」 束:無]; s.view .frame = CGRectMake(10,20,745,755); s.object = self; [self.navigationController pushViewController:s animated:YES]; }); – stosha

0

self.navigationController(你模態地呈現)將爲零

並且您無法注意到這一點,因爲您正在分配導航控制器對象。

+0

因此,任何想法請 –

+0

從先前的視圖控制器獲得導航控制器對象的引用,並使用它再次推視圖控制器。 –

相關問題