1

我找到了滑动视图并放置 ViewController 的代码,但我不想放置 ViewController,我需要添加到幻灯片菜单的视图位于同一个视图控制器中。我只需要在左下幻灯片中添加这个 UIView。

OBS.:我没有在这个项目中使用故事板。我需要在滑动视图中添加一个 UIView

这是添加 ViewController 的代码:

  - (void)viewWillAppear:(BOOL)animated
{
  [super viewWillAppear:animated];

  // shadowPath, shadowOffset, and rotation is handled by ECSlidingViewController.
  // You just need to set the opacity, radius, and color.
  self.view.layer.shadowOpacity = 0.75f;
  self.view.layer.shadowRadius = 10.0f;
  self.view.layer.shadowColor = [UIColor blackColor].CGColor;

  if (![self.slidingViewController.underLeftViewController isKindOfClass:[MenuViewController class]]) {
    self.slidingViewController.underLeftViewController  = [self.storyboard instantiateViewControllerWithIdentifier:@"Menu"];
  }

  [self.view addGestureRecognizer:self.slidingViewController.panGesture];
}
4

1 回答 1

1

我想你正在使用ECSlidingViewController...

underLeftViewController是一个属性,指的是一个视图控制器。

您必须创建一个继承自 UIViewController 的新类并实例化它。然后你将它分配给underLeftViewController

MyViewController *vc = [[MyViewController alloc] init];
self.slidingViewController.underLeftViewController  = vc;

否则,如果您不想创建一个新类,您可以声明一个基本视图控制器并将其分配给underLeftViewController

UIViewController *vc = [[UIViewController alloc] init]
//settings for vc
self.slidingViewController.underLeftViewController  = vc;
于 2013-08-28T14:11:09.467 回答