滑动菜单作为Facebook应用程序

时间:2013-08-28 14:01:50

标签: ios objective-c uiview ios4 ecslidingviewcontroller

我找到了一个代码,可以滑动de view并放置一个ViewController,但我不想放置一个ViewController,我需要添加到幻灯片菜单的视图位于同一个viewcontroller中。我只需要将这个UIView添加到underleft幻灯片中。

OBS:我没有在这个项目上使用故事板。我需要在slidingView

中添加一个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];
}

1 个答案:

答案 0 :(得分: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;