我已经为侧边菜单实施了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)(我将知道如何解决),然后发送到这个将打开的新视图控制器。
我该怎么做?
答案 0 :(得分:1)
您可以使用UIViewController的子类代替“内容”视图控制器的库存UIViewController类。在此子类上,您可以添加
@property (strong, nonatomic) NSString *stringForContentView;
然后,就在您将“内容”视图控制器添加为当前视图控制器的子项的行上方,
content.stringForContentView = @"A string that you already have";