标签:
从BViewController传到AViewController
在BViewController.h中
#import <UIKit/UIKit.h>
@protocol IDDelegate <NSObject>
- (void)setIDValue:(NSString *)value;
@end
@interface BViewController : UIViewController
@end
在BViewController.m中
#import "BViewController.h"
@interface BViewController ()
@property(nonatomic, retain) id<IDDelegate> idDelegate; // 注册一个代理
@end
self.idDelegate = a; // 这里和AViewController 进行交互,下一句代码就是对应的赋值
[self.idDelegate setIDValue:stringValue];
[self.navigationController popToViewController:qvc animated:true];
#import "BViewController.h" // 导入协议
@interface AViewController : UIViewController<IDDelegate>// 遵守协议
@property (strong, nonatomic) UITextField *contactIdField;
- (void)setIDValue:(NSString *)value;
@end
在AViewController.m中
- (void)setIDValue:(NSString *)value // 实现方法
{
self.contactIdField.text = value ;
}
标签:
原文地址:http://www.cnblogs.com/pjl111/p/4244858.html