从UIPageViewController的Root View Controller执行Segue

时间:2014-09-29 17:31:02

标签: ios objective-c

我有一个UIPageViewController,里面有一个按钮。每当按下按钮时,我想从父视图控制器(嵌入了导航控制器)执行Segue到导航堆栈中的下一个视图控制器。我还希望能够通过segue传递数据。我尝试了很多东西,但我对iOS开发很新,并且根本没有成功。

1 个答案:

答案 0 :(得分:0)

您需要在故事板中选择segue,并在下面的代码中为其提供唯一标识符和放置。

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{

if ([segue.identifier isEqualToString:@"YourSegueIdentifier"]) {
    // get a reference to the destination View Controller
    UIViewController *destinationVC = [segue destinationViewController];
    XXYourViewControllerSubclass *yourVC = (XXYourViewControllerSubclass*)destinationVC;
    // create the data and pass it to the view controller
    id someData = // create your data (unless you have a property holding it already)
    [yourVC acceptData:(id)someData]; // make a public method on your VC subclass to accept the data
}
// after this method has returned the seque will be performed
}

这有意义吗?