ipad中popover控制器的转换

时间:2012-04-23 03:13:34

标签: iphone ipad uinavigationcontroller uipopovercontroller

当我点击这个按钮时,你会看到一个用于搜索视图中文本的popover ..但是当我输入god时,带有go的句子进入popover控制器tableviewcell,当我点击单元格时,搜索结果显示在popover本身,它没有重定向到mainvieww.my代码或popover控制器是

- (void)Searchpage:(id)sender {
    searchpage* popoverContent = [[searchpage alloc]
                                  init];    
    UINavigationController *navigationController = [[[UINavigationController alloc] initWithRootViewController:popoverContent] autorelease];

    //resize the popover view shown
    //in the current view to the view's size
    popoverContent.contentSizeForViewInPopover =
    CGSizeMake(320,650);

    //create a popover controller
    self.popoverController = [[UIPopoverController alloc]
                              initWithContentViewController:navigationController];
    //present the popover view non-modal with a
    //refrence to the button pressed within the current view
    [self.popoverController presentPopoverFromRect:CGRectMake(600, 0, 0, 0)
                                            inView:self.view
                          permittedArrowDirections:UIPopoverArrowDirectionAny
                                          animated:YES];

    //release the popover content

    [popoverContent release];    

}

在搜索页面弹出控制器中,我将此代码重定向到主视图

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    // Navigation logic may go here. Create and push another view controller.
    ParallelReadViewController *detailViewController = [[ParallelReadViewController alloc] initWithNibName:@"ParallelReadViewController" bundle:nil];


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

    [detailViewController release];    
    delegate.selectedBook = [[searchResults objectAtIndex:indexPath.row] objectForKey:@"book"];
    delegate.selectedChapter = [[searchResults objectAtIndex:indexPath.row] objectForKey:@"chapter"];
    delegate.selectedVerse = [[searchResults objectAtIndex:indexPath.row] objectForKey:@"verse"];
    [delegate reloadVerses];


}

parallelViewController是Main视图,但现在我在popover controller.i中获取Mainview只想关闭此popover控制器并导航到parallelviewcontroller.how来执行此操作。 提前谢谢。

1 个答案:

答案 0 :(得分:0)

您可以使用

- (void)dismissPopoverAnimated:(BOOL)animated

解除popover的方法。

可以参考以下链接获取更多信息 - http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIPopoverController_class/Reference/Reference.html

编辑 - 您可以使用 -

获取包含popover的类
NSArray *viewControllerArray = [[self.navigationController.viewControllers copy] autorelease];
int arrayElementCount = [viewControllerArray count];
YourViewController *aViewController;
for(int index = 0 ; index < arrayElementCount ; index++) {
    if([[viewControllerArray objectAtIndex:index] isKindOfClass:[YourViewController class]]) {
        aViewController = [viewControllerArray objectAtIndex:index];
    }       
}
[aViewController.popoverController dismissPopoverAnimated:YES];