1

popovercontroller要显示一个搜索页面,它很好地显示了搜索页面,当用户点击弹出框内的单元格时,它会在里面显示相应的页面popovercontroller,我不想要它,所以我放了NSNotification用于显示的popover,它工作正常,但我有一个问题,但导航没有发生在那里popovercontroller,只有解雇发生。这是我创建弹出框的代码

-(void)revealRightSidebar:(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.popup = [[UIPopoverController alloc]
                              initWithContentViewController:navigationController];

    [self.popup presentPopoverFromRect:_btnsearch.frame
                                            inView:self.view
                          permittedArrowDirections:UIPopoverArrowDirectionAny
                                          animated:YES];

    //release the popover content

    [popoverContent release];    

    [self resetReadViewToVerse:1];
}

viewDidLoad这个页面的方法中,我把通知

- (void)viewDidLoad
{
    [super viewDidLoad];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dismissThePopover) name:@"popoverShouldDismiss" object:nil];
}

在 searchpage 我把这段代码导航到相应的搜索结果页面

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{          
     ParallelReadViewController *detailViewController = [[ParallelReadViewController alloc] initWithNibName:@"ParallelReadViewController" bundle:nil];

     //detailViewController.firstString = firstString;
     // ...
     // Pass the selected object to the new view controller.

     [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];
     [[NSNotificationCenter defaultCenter] postNotificationName:@"popoverShouldDismiss" object:nil];
}

但是当我删除通知时,它会导航到parallelReadViewController页面中的相应搜索,但在其popover本身中,这里是popover关闭,但没有导航。请帮我这样做。

4

1 回答 1

0

您必须navigationController在类中声明AppDelegate。使用它navigationController来推送所需的视图。

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath  
{                 
    ParallelReadViewController *detailViewController = [[ParallelReadViewController alloc] initWithNibName:@"ParallelReadViewController" bundle:nil];         
   //detailViewController.firstString = firstString;       
   // ...   
   // Pass the selected object to the new view controller. 
   [delegate.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];
   [[NSNotificationCenter defaultCenter] postNotificationName:@"popoverShouldDismiss" object:nil];
}

希望这可以帮助你......

于 2012-05-17T13:00:51.710 回答