gpt4 book ai didi

ios - 如何将对象从一个 View 发送到另一个 View ?

转载 作者:行者123 更新时间:2023-11-29 04:20:11 24 4
gpt4 key购买 nike

我已经实现了 SASlideMenu对于侧面菜单来说,除了一件事之外,一切都很棒。我不知道如何发送对象。

这是发生的 View 切换:

-(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)(我将知道如何解决),然后发送到这个将打开的新 View Controller 。

我该怎么做?

最佳答案

您可以使用 UIViewController 的子类来代替“内容” View Controller 的常用 UIViewController 类。在此子类上,您可以添加

@property (strong, nonatomic) NSString *stringForContentView;

然后,在将“内容” View Controller 添加为当前 View Controller 的子级的行上方,

content.stringForContentView = @"A string that you already have";

关于ios - 如何将对象从一个 View 发送到另一个 View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13077922/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com