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

标签 ios iphone uinavigationbar

我有一个问题。当我按下 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/

相关文章:

ios - 如何将 NSKeyedUnarchiver unarchiveObjectWithData 更新为 NSKeyedUnarchiver unarchivedObjectOfClass :[fromData:error:

iphone - UIView 如何访问 UIViewController 的属性?

ipad - UINavigationController:Resize动画中标题跳转

ios - 移动到新 View Controller 时隐藏导航栏

ios - 重用自定义 tableViewCell 单元格中的隐藏按钮 [ios]

ios - 创建一个新的Cocoapod : use example project for remote repo?

iphone - 在 scrollViewWillBeginDragging 中检测 UIScrollView 滚动的方向

iphone - 单独的按钮 Action 和segue Action

ios - 使用 set RightBarButtonItem 时出现两个按钮

ios - 如何在 iPhone/iPad 中播放流式音频