在ipad中从popOver推送视图

时间:2013-01-24 06:21:59

标签: ios objective-c cocoa-touch uipopovercontroller

我在视图(MapView)中打开一个带有视图(DetailView)的popOver。它工作正常。

但在我的详细视图中有一个按钮(反馈)。所以我想在btton上点击另一个视图(feedbackform)。

我试过但没有发生任何事情。

我可以在弹出框内推送视图吗?

我的代码如下:

// MapView.m

detailsView *popUp=[[detailsView alloc] initWithNibName:@"detailsView_ipad" bundle:nil];


        popView = [[UIPopoverController alloc]initWithContentViewController:popUp];

        popView.delegate =self;

        [popView setPopoverContentSize:CGSizeMake(600, 500)];

 [popView presentPopoverFromRect:control.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];

}  


//Detailview.m

-(IBAction)openFeedbackForm:(id)sender {

fbView = [[deatailsFeedback alloc]
                  initWithNibName:@"deatailsFeedback_ipad" bundle:nil];
 [self.navigationController pushViewController:fbView animated:YES];
}

2 个答案:

答案 0 :(得分:1)

要实现这一点,您的detailsView应该是一个导航控制器,其根控制器与原始detailsView。

相同

这样当你弹出navigationController时,你可以从你的detailsView执行推送,这只会影响popOver视图

    detailsView *popUpView=[[detailsView alloc] initWithNibName:@"detailsView_ipad" bundle:nil];

    UINavigationController *popUpNavController = [[UINavigationController alloc] initWithRootViewController:popUpView];    

    popView = [[UIPopoverController alloc]initWithContentViewController:popUpNavController];

    popView.delegate =self;

    [popView setPopoverContentSize:CGSizeMake(600, 500)];

    [popView presentPopoverFromRect:control.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp animated:YES];

}


//Detailview.m

-(IBAction)openFeedbackForm:(id)sender {

    fbView = [[deatailsFeedback alloc]
              initWithNibName:@"deatailsFeedback_ipad" bundle:nil];
    [self.navigationController pushViewController:fbView animated:YES];
}

答案 1 :(得分:0)

如果我正确理解您的代码,openFeedForm IBAction方法在Detailview.m中? 这意味着代码的第一部分与底部的类不同?

如果是这样,由于Detailview本身不在navigationController中,它不会将任何内容推送到其不存在的导航控制器。

你想要做的是让MapView在其navigationController中推送新视图。

旁注:由于您在MapView中将popUp的委托设置为(self),因此应在MapView中定义IBAction方法

(这是假设我关于理解你的代码的第一个陈述是正确的)