0

我有三页。每个页面都将一些值推送到下一页,如下所示: bookpage----------values passing to >chapterpage---------values passing to>verse page。当用户从主页点击按钮时,它会显示一个带有书页的模型表单。代码是:

    BookSelectionview *detailViewController = [[BookSelectionview alloc] initWithNibName:@"BookSelectionview" bundle:nil];

    UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:detailViewController];
    navController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    navController.modalPresentationStyle = UIModalPresentationFormSheet;

    UIBarButtonItem *doneBarButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone
                                                                                   target:self
                                                                                   action:@selector(modalViewDone)];
    detailViewController.navigationItem.rightBarButtonItem = doneBarButton;
    detailViewController.navigationItem.title = @"Book Selection";
    [doneBarButton release];

    [self.navigationController presentModalViewController:navController animated:YES];
    [detailViewController release];
    [navController release];
    [self resetReadViewToVerse:1];
}

然后在我的章节页面中,我编写了这段代码来导航并将一些值传递给 verse 页面。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{         
    ChapterSelectionView *detailViewController = [[ChapterSelectionView alloc] initWithNibName:@"ChapterSelectionView" bundle:nil];
    detailViewController.contentSizeForViewInPopover = CGSizeMake(500, 600);

    //detailViewController.firstString = firstString;
    // ...
    // Pass the selected object to the new view controller.
    detailViewController.selectedIndex=indexPath.row;
    appDelegate.selectedBookIndex=indexPath.row;
    self.hidesBottomBarWhenPushed=YES;
    [self.navigationController pushViewController:detailViewController animated:YES];

    [detailViewController release];         
}

在经文页面中是问题....在页面中包含圣经经文,它是按钮形式,当使用点击任何按钮时,它需要转到主视图并显示相应的经文,但它显示了表单内的主页,与对应的诗句..所以我把dismissmodelview动画:是的代码。但它兑现..我的诗句页面中的代码在按钮点击

appDelegate.selectedBook = [appDelegate.books objectAtIndex:appDelegate.selectedBookIndex];
appDelegate.selectedChapter = [NSString stringWithFormat:@"%d",appDelegate.selectedChapterIndex];
appDelegate.selectedVerse = [NSString stringWithFormat:@"%d",[sender.titleLabel.text intValue]];
[appDelegate reloadVerses];

ParallelReadViewController *detailViewController = [[ParallelReadViewController alloc] initWithNibName:@"ParallelReadViewController" bundle:nil];

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

[detailViewController release];
[self.navigationController dismissModalViewControllerAnimated:YES];

如何关闭表单并使用相应的经文转到主页(parallelreadviewcontroller)?

4

1 回答 1

0

在主视图的 viewDidLoad 中添加通知

[[NSNotificationCenter defaultCenter] addObserver:self 
                                         selector:@selector(dismissTheModelView:) 
                                             name:@"dismissTheModelView" 
                                           object:nil];

在主视图中写入函数

-(void)dismissTheModelView:(id)sender
{
     [self dismissModalViewControllerAnimated:YES];
}

最后发布通知,您必须关闭弹出框控制器,例如

-(IBAction)cancelButtonPressed:(id)sender
{
    [[NSNotificationCenter defaultCenter] postNotificationName:@"dismissTheModelView" object:nil];
}
于 2012-06-07T10:59:33.647 回答