0

我已经为侧边菜单实现了 SASlideMenu,除了一件事之外,一切都很出色。我不知道如何发送对象。

这是正在发生的切换视图:

-(void) switchToContentViewController:(UIViewController*) content{

    CGRect bounds = self.view.bounds;
    if (selectedContent) {


        //Animate out the currently selected UIViewController
        [UIView animateWithDuration:kSlideOutInterval delay:0.0 options:UIViewAnimationCurveEaseInOut animations:^{
            selectedContent.view.frame = CGRectMake(bounds.size.width,0,bounds.size.width,bounds.size.height);
        } completion:
         ^(BOOL completed) {

             [selectedContent willMoveToParentViewController:nil];
             [selectedContent.view removeFromSuperview];
             [selectedContent removeFromParentViewController];

             content.view.frame = CGRectMake(bounds.size.width,0,0,bounds.size.height);
             [self addChildViewController:content];
             [self.view addSubview:content.view];
             [UIView animateWithDuration:kSlideInInterval delay:0.0 options:UIViewAnimationCurveEaseInOut animations:^{
                 content.view.frame = CGRectMake(0,0,bounds.size.width,bounds.size.height);

             } completion:^(BOOL completed){
                 selectedContent = content;
                 [content didMoveToParentViewController:self];
                 [self.shield removeFromSuperview];
             }];
         }];
    }else{
        [self addChildViewController:content];
        [self.view addSubview:content.view];
        content.view.frame = CGRectMake(0,0,bounds.size.width,bounds.size.height);
        selectedContent = content;
        [self.shield removeFromSuperview];
        [content didMoveToParentViewController:self];
    }
}

我想要的是在这里获取标识符(NSString)(我会知道如何解决),然后发送到这个将打开的新视图控制器。

我怎样才能做到这一点?

4

1 回答 1

1

您可以为“内容”视图控制器使用 UIViewController 的子类,而不是使用现有的 UIViewController 类。在这个子类上,您可以添加一个

@property (strong, nonatomic) NSString *stringForContentView;

然后,就在您将“内容”视图控制器添加为当前视图控制器的子项的行上方,

content.stringForContentView = @"A string that you already have";
于 2012-10-25T22:02:15.950 回答