2013-01-09 25 views
1

在我的應用程序中,我展示了一個模態視圖。在模態視圖中,我採取了一個視圖(Extraview),其中包含一個表視圖&的一個按鈕。通過iPhone SDK中的彈出式表格行關閉模式視圖

從這個按鈕,我打開包含視圖(LeftsideView)的popview。

-(IBAction)popOverBtnPressed:(id)sender 
{ 
    LeftSideVCViewController *popUp=[[LeftSideVCViewController alloc] initWithNibName:@"LeftSideVCViewController" bundle:nil]; 



    popView = [[UIPopoverController alloc]initWithContentViewController:popUp]; 
    popView.delegate =self; 

    [popView setPopoverContentSize:CGSizeMake(300, 700)]; 
    [popView presentPopoverFromRect:CGRectMake(150,30,20,40) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES]; 

} 

enter image description here enter image description here

現在,我想解僱萊夫特賽德視圖的錶行的選擇模式的看法。 我該如何做到這一點。

回答

2
在您的問題呈現酥料餅

是不同類和罷免方法是不同的類,所以你需要像貝婁實施NSNotificationCenter: - 在你的酥料餅創建的類在ViewDidLoad方法

新增通知: -

- (void)viewDidLoad 
{ 

    [[NSNotificationCenter defaultCenter] addObserver:self 
              selector:@selector(dismisPopoverInnerPageTeam:) 
               name:@"InnerPop" 
               object:nil]; 


    [super viewDidLoad]; 

} 

-(void)dismisPopoverInnerPageTeam:(NSNotification *)notification { 

    [yourPopOver dismissPopoverAnimated:YES]; 
} 

現在你只需要調用此方法從您的LeftSideVCViewControllerUITableView Delegate方法didSelectRowAtIndexPath,如: -

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    [[NSNotificationCenter defaultCenter] postNotificationName:@"InnerPop" object:self]; 

} 

希望這是幫助您:)

+0

我也試過這個,但得到如下錯誤:[Reader_View dismissModal]:無法識別的選擇器發送到實例0xB494e10 2013-01-08 16:12:00.468 AFFeedsReader [3449:1d903] ***終止應用程序由於未捕獲的異常'NSInvalidArgumentException',原因:' - [Reader_View dismissModal]:無法識別的選擇器發送到實例0xb494e10 – user1673099

+0

刪除dismis modelViewCode你需要關閉popover不是ModelView以及如何dismisModelView未打開它? –

0

嘗試這種情況:

[popoverController dismissPopoverAnimated:YES];

+0

我不想關閉popover,我想解僱提出的模態視圖。 – user1673099

+0

試試這個:[self dismissViewControllerAnimated:YES completion:nil]; – Vishal

+0

它不工作..我已經試過這個。 – user1673099

0

我解決了這個如下:

註冊後通知之後。

您必須首先關閉彈出框&然後關閉顯示的模態視圖。

-(void)dismissModal:(NSNotification *)notification 
{ 

    [popView dismissPopoverAnimated:YES]; 
    [self dismissViewControllerAnimated:YES completion:nil]; 


}