iPhone中的导航疑惑

时间:2011-11-30 07:14:38

标签: iphone

我必须将值从一个视图控制器传递给另一个视图控制器,我的代码工作正常

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];

但我想通过这种方式传递localStringtextnote

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

如何通过上面的rediriction方法传递一个值?我希望你能理解我的问题。提前谢谢。

1 个答案:

答案 0 :(得分: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,一次只使用一个)。