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