2011-11-30 89 views
0

我必须从一个视图 - 控制器到另一个视图 - 控制器传递值,我的这个代码工作正常导航疑惑

NSString *localStringtextnote; 

-(IBAction)_clickbtnsyncNote:(id)sender 
{ 
localStringtextnote = textVieww.text; 
     Googledocmainpage *detailViewController = [[Googledocmainpage alloc] initWithNibName:@"Googledocmainpage" bundle:nil]; 

     detailViewController.localStringtextnote = localStringtextnote; 
     // ... 
     // Pass the selected object to the new view controller. 

     [self.navigationController pushViewController:detailViewController animated:YES]; 

     [detailViewController release]; 

,但我想通过这样的方式

Googledocmainpage *aSecondViewController = [[Googledocmainpage alloc] initWithNibName:@"Googledocmainpage" bundle:nil]; 
    aSecondViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical; 
    [self presentModalViewController:aSecondViewController animated:YES]; 
    [self.navigationController pushViewController:aSecondViewController animated:YES]; 
通过localStringtextnote

如何通过上述页面重新定义方法传递一个值?我希望你理解我的问题。

回答

1

这样

Googledocmainpage *aSecondViewController = [[Googledocmainpage alloc] initWithNibName:@"Googledocmainpage" bundle:nil]; 

aSecondViewController.localStringtextnote = localStringtextnote; 

    aSecondViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical; 
    [self presentModalViewController:aSecondViewController animated:YES]; 
    // [self.navigationController pushViewController:aSecondViewController animated:YES]; 

也用你为什么要使用这两种方式(推的观点和presentModelView,只能使用一个在时间)。

+0

yeaa u r right right it fine。 – ICoder