1

当我单击此按钮时,您会弹出一个用于在视图中搜索文本的弹出窗口..但是当我输入上帝时,带有 go 的句子进入弹出框控制器 tableviewcell 内,当我单击单元格时,搜索结果显示在弹出框本身,它没有重定向到 mainvieww.my 代码或弹出框控制器是

- (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 是主视图,但现在我在弹出框控制器中获得主视图。我只想关闭此弹出框控制器并导航到 parallelviewcontroller。如何执行此操作。提前致谢。

4

1 回答 1

0

您可以使用

- (void)dismissPopoverAnimated:(BOOL)animated

关闭弹出框的方法。

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

编辑-您可以使用以下方法获取包含弹出框的类-

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];
于 2012-04-23T04:12:06.113 回答