underLeftViewController

underLeftViewController

我已经找到了可以在视图上滑动并放置ViewController的代码,但是我不想放置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];
}

最佳答案

我认为您正在使用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;

10-05 20:21