与您要弹出从后面的VC,你需要给它一个代表属性 -
@class MyViewController;
@protocol MyViewControllerDelegate <NSObject>
-(void)myViewControllerDidDismiss:(MyViewController *)controller withSomeObject:(id)someObject;
@end
@interface MyViewController : UIViewController
@property (nonatomic, assign) id<MyViewControllerDelegate> myViewControllerDelegate;
@end
...并在根VC你使其符合该协议,并实施罢免法 -
-(void)myViewControllerDidDismiss:(MyViewController *)controller withSomeObject:(id)someObject {
// now I've got the object from the VC I just popped
}
忘了提,你需要调用myViewControllerDidDismiss:withSomeObject:当你弹出的VC。
编辑 - 也忘了提,你需要设置VC的委托作为你的根VC,当你创建它,否则它会试图调用为零,当你弹回 -
[myViewController setMyViewControllerDelegate:self];
学会使用委托......这将是非常有益的。 – 2012-04-13 11:27:37
从什么时候开始,团队不工作?! – SomaMan 2012-04-13 11:34:59
整个iPhone sdk基于委派...你怎么能说它不适用于ios5 ...任何书面证明,你可以指导我太.. ..? @AalokParikh – 2012-04-13 11:40:07