2012-05-17 77 views
1

我有一個popovercontroller來顯示一個搜索頁面,它顯示了很好的搜索頁面,當用戶點擊popover內的單元格時,它會顯示popovercontroller內的相應頁面,我不想要它,所以我把NSNotification用於顯示popover,它工作正常,但我遇到了一個問題,但導航不在popovercontroller那裏發生,只有解僱發生。 這是我的代碼在本頁面viewDidLoad方法來創建酥料餅UIPopOverViewControler解僱問題

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

我把通知

- (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解僱,但沒有navigation.please幫我做到這一點。

+0

@Atulkumar V.Jain從烏爾側任何幫助嗎? – stackiphone

回答

0

您必須在AppDelegate類中聲明navigationController。使用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]; 
} 

希望這可以幫助你.......

+0

@AthulKumar V.Jain,我把你的代碼,但沒有運氣... – stackiphone