gpt4 book ai didi

ios - Iphone 传递对象(导航栏上的按钮返回)

转载 作者:行者123 更新时间:2023-11-29 05:07:28 25 4
gpt4 key购买 nike

我有一个问题。当我按下 UINavigationBar 中的后退按钮时,如何传递并反对上一个 View ?

最佳答案

如果您在当前的 VC 中有一个指向您的 View 的链接,如下所示:

previousVC.objectToPass = objectToPass;

或者使用这样的通知:

1 - 在你的后面方法中:

 [[NSNotificationCenter defaultCenter] postNotificationName:@"PassObject" withObject:objectToPass];

2 - 在您之前的 VC 中:

- (void) didReceiveNotificationPassObject:(NSNotification*)notification  
{
YourObjectClass *theObject = (YourObjectClass*)notification.object;
}

3 - 在您之前的 VC 的 init 中:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didReceiveNotificationPassObject:) name:@"PassObject" object:nil];

关于ios - Iphone 传递对象(导航栏上的按钮返回),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4254981/

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