实例方法'-presentViewController:animated'未找到

时间:2013-04-19 01:53:15

标签: ios objective-c cocoa-touch uiviewcontroller

我对此很新,所以请耐心等待。我的代码中还有2个错误要修复。在这两种情况下都找不到我的实例方法:

-(IBAction)goFlipSide {
    NSLog(@"goFlipSide has been called:");
    FlipsideViewController *controller = [[FlipsideViewController alloc] initWithNibName:@"FlipsideViewController" bundle:nil];

    controller.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    [self presentViewController:controller animated:YES];

    [controller release];
}

- (void)flipsideViewControllerDidFinish:(FlipsideViewController *)controller {
    [self dismissViewControllerAnimated:YES];

    //This method gets fired when the user clicks done on the modal FlipsideViewController.  This is different
    //than the viewWillAppear.
    self.navigationController.navigationBarHidden = TRUE;
    /*
    if (self.goViewSuccess == TRUE) {
        //if the goViewSuccess boolean is set to YES - then we can load the load the goViewController
        NSLog(@"goViewSuccess is YES");
        [self loadGoViewController];
    }
    */
}

找不到两种实例方法:presentViewController:dismissViewControllerAnimated:

2 个答案:

答案 0 :(得分:4)

什么类是self?这些方法仅在UIViewController上找到。完整的选择器是:

  • presentViewController:animated:completion:
  • dismissViewControllerAnimated:completion:

尝试添加完成块参数。

答案 1 :(得分:0)

代码应该是这个

[self dismissViewControllerAnimated:YES completion:nil];

或者如果你想要完成它,

[self dismissViewControllerAnimated:YES completion:^{
//do stuff
}];

另一个

[self presentViewController:controller animated:YES completion:nil];