让我知道这段代码的功能

时间:2014-05-09 05:17:47

标签: ios objective-c uinavigationcontroller swrevealviewcontroller

我是ios的新手。我正在调试代码,我已经完成了以下几行,我不懂功能。如果有人理解,请告诉我。

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

   if ( [segue isKindOfClass: [SWRevealViewControllerSegue class]] ) {

        SWRevealViewControllerSegue *swSegue = (SWRevealViewControllerSegue*) segue;
      __typeof(self) __weak weakSelf = self;

      swSegue.performBlock = ^(SWRevealViewControllerSegue* rvc_segue, UIViewController* svc, UIViewController* dvc){

            UINavigationController* navController = (UINavigationController*) weakSelf.revealViewController.frontViewController;
            [navController setViewControllers: @[dvc] animated: NO ];
            [weakSelf.revealViewController setFrontViewPosition: FrontViewPositionLeft animated: YES];

      };

    }

}

1 个答案:

答案 0 :(得分:4)

您可以使用“prepareForSegue”方法推送到新的viewcontroller

但是在此代码中,在推送目标视图控制器期间将执行自定义segue来代替本机动画

SWRevealViewControllerSegue是自定义segue的类,你可以在那里看到推送动画代码。