解雇ModalViewControllerAnimated后将参数设置为超级视图

发布于 2024-10-08 23:59:10 字数 689 浏览 7 评论 0原文

我有 2 个视图(视图 A 和视图 B)。

在 viewA 中,当我触摸按钮时,我执行此代码来翻转 viewB:

viewB.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:viewB animated:YES];

现在,当我回到 viewA 时,我使用此代码:

[self dismissModalViewControllerAnimated: YES]; //here is my problem

当我执行关闭时,我需要为 viewA 设置相同的参数。 我该怎么做呢?

编辑 我还没有找到任何解决方案,我以这种方式使用了pushNavigation:

FirstViewController *viewA = [self.storyboard instantiateViewControllerWithIdentifier:@"myView"];

// Effettuo il push alla view successiva
[self.navigationController pushViewController:viewA animated:YES];

I have 2 view (view A and view B).

In viewA when I touch a button I execute this code to flip a viewB:

viewB.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:viewB animated:YES];

And now when I came back to viewA I use this code:

[self dismissModalViewControllerAnimated: YES]; //here is my problem

I need to set same parameters to viewA when I execute dismiss.
How can I do it?

EDIT
I have not found any solution and I used a pushNavigation in this way:

FirstViewController *viewA = [self.storyboard instantiateViewControllerWithIdentifier:@"myView"];

// Effettuo il push alla view successiva
[self.navigationController pushViewController:viewA animated:YES];

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

糖粟与秋泊 2024-10-15 23:59:10

搜索委托示例或简单地使用 NSNotificationCenter 将消息从一个视图发送到另一个

视图 ClassA:

@protocol myDelegate

@interface ClassA : UIViewController {

}

@end

@protocol myDelegate
- (void)thingsDone:(id)someValues;
@end

ClassB:

#import "ClassA.h"
@interface ClassB : UIViewController <myDelegate> {

}
@end

search for a delegate example or simply use NSNotificationCenter to send a message from one view to another

ClassA:

@protocol myDelegate

@interface ClassA : UIViewController {

}

@end

@protocol myDelegate
- (void)thingsDone:(id)someValues;
@end

ClassB:

#import "ClassA.h"
@interface ClassB : UIViewController <myDelegate> {

}
@end
倾听心声的旋律 2024-10-15 23:59:10

您有两个选择:

1- 您可以使用委托模式 并将 viewA 注册为委托对象:

viewB.delegate = self;
[self presentModalViewController:viewB animated:YES];

在 vi​​ewB 中,您可以向委托发送消息:

[delegate someMethod];

2- 您可以在 viewB 中保留指向 viewA 的指针:

viewB.viewA = self;
[self presentModalViewController:viewB animated:YES];

然后您可以直接向 viewA 发送消息:

[viewA someMethod];

You have two options:

1- You can use the delegate pattern and register viewA as the delegate object:

viewB.delegate = self;
[self presentModalViewController:viewB animated:YES];

And in viewB you can send messages to the delegate:

[delegate someMethod];

2- You can keep a pointer to viewA in viewB:

viewB.viewA = self;
[self presentModalViewController:viewB animated:YES];

And then you can send messages to the viewA directly:

[viewA someMethod];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文