意义:两个Controller A(SelectDeviceThroughGatewayViewController) B(ScanViewController)
A调用B后,返回A
A中需要显示B回传的值
在B中:
.h
@class ScanViewController;
@protocol PassValueDelegate <NSObject>
-(void)passValue:(NSString *)value;
@end
@interface ScanViewController : UIViewController
@property (nonatomic,weak) id<PassValueDelegate> delegate;
@end
.m 中需要回传值的地方
if ([self.delegate respondsToSelector:@selector(passValue:)]) {
[self.delegate passValue:[obj stringValue]];
}
A.m
@interface SelectDeviceThroughGatewayViewController ()<PassValueDelegate>
A在调用B时处理delegate
ScanViewController *controller = [[ScanViewController alloc]init];
controller.delegate = self;
[self presentViewController:controller animated:YES completion:nil];
A中处理返回的值
-(void)passValue:(NSString *)value{
NSLog(@"----get backcall value=%@",value);
self.dayLabel.text = value;
}