2012-04-26 21 views
0

我有三個頁面。每個頁面將這些值推送到下一頁,如下所示:bookpage ---------- values passed to> chapterpage ---------- values passed to> verse page。當用戶點擊主頁面上的按鈕時,它會顯示一個包含書頁的模型表單。代碼是這樣的:如何解除iPhone中的表單模型視圖

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

然後在我的章節頁面中,我編寫了這段代碼來導航並將一些值傳遞給詩句頁面。

- (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)與相應的詩句?

+0

先嚐試解除模態,然後推動你的視圖控制器。 – rishi 2012-04-26 04:57:41

+0

@RIP我把[self.navigationController dismissModalViewControllerAnimated:YES];上方..ParallelReadViewController * detailViewController = [[ParallelReadViewController alloc] initWithNibName:@「ParallelReadViewController」bundle:nil]; [self.navigationController pushViewController:detailViewController animated:YES]; [detailViewController release]; [self.navigationController dismissModalViewControllerAnimated:YES]; ..但再次崩潰應用程序 – stackiphone 2012-04-26 05:15:21

+0

@RIP有沒有辦法做到這一點? – stackiphone 2012-04-26 05:24:02

回答

0

在主視圖中的viewDidLoad添加通知

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

寫功能在主視圖

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

終於發佈從那裏u必須駁回酥料餅的控制器的通知,像

-(IBAction)cancelButtonPressed:(id)sender 
{ 
    [[NSNotificationCenter defaultCenter] postNotificationName:@"dismissTheModelView" object:nil]; 
} 
+0

難道你不能把它放在IBAction? ' - (IBAction)cancelButtonPressed:(id)sender {[self dismissModalViewControllerAnimated:YES]; }' – Samin 2014-08-30 17:31:05

相關問題