UIPopOverViewControler中的解雇问题

时间:2012-05-17 11:07:15

标签: iphone ios ios5 uipopovercontroller

我有popovercontroller来显示搜索页面,它会显示搜索页面,当用户点击popover中的单元格时,它会显示popovercontroller内的相应页面,我不想要它,所以我把NSNotification用来显示popover,它运行正常,但是我遇到了一个问题,但popovercontroller中没有发生导航,只有解雇才会发生。 这是我创建一个popover的代码

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

在搜索页面中,我将此代码导航到相应的搜索结果页

- (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解除,但没有导航。请帮助我这样做。

1 个答案:

答案 0 :(得分: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];
}

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