如何在iPhone中关闭表单工作表模型视图 [英] how to dismiss a Form sheet model view in iPhone

查看:55
本文介绍了如何在iPhone中关闭表单工作表模型视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有三页.每个页面都将一些值推入下一页,如下所示:bookpage ----------传递给> chapterpage的值----------传递给> verse页面的值.当用户从主页上点击按钮时,它会显示一个带有书页的模型表单.的代码是:

I have three pages. Each page pushes some values to next page like this: bookpage----------values passing to >chapterpage----------values passing to>verse page. When the user taps the button from the main page it shows a model form sheet which has book page. The code for this is:

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

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

Then in my chapter page I wrote this code to navigate and pass some value to verse page.

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

在经文页面中是个问题....在此页面中包含圣经经文,当用户点击任意按钮时,它以按钮的形式出现,它需要进入主视图并显示相应的经文,但是它显示了表单中的主页,并带有相应的verse..so,所以我将dismissmodelview动画设置为:是的对代码进行了编码.

and in verse page here is the problem....in tho page includes bible verse which is in the form of buttons when the use tap any button it need to go to the main view and show the corresponding verse,,but it shows the main page inside the form sheet,with the correspondent verse..so i put the dismissmodelview animated:yes to the code.but it cashes..my code in verse page its in button click

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)?

How can I dismiss the form sheet and go to main page(parallelreadviewcontroller) with the corresponding verse?

推荐答案

在主视图的viewDidLoad中添加通知

Add a notification in main view's viewDidLoad

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

在主视图中写入功能

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

,最后从您必须关闭弹出窗口控制器的位置发布通知,例如

and finally post the notification from where u have to dismiss the popover controller, like

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

这篇关于如何在iPhone中关闭表单工作表模型视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆