在关闭当前视图控制器后,我创建了一个委托将数据传回前一个视图控制器。
这就是我设置代表的方式
PaymentViewController.m
-(IBAction)techProcessAction:(id)sender
{
TechProcessPaymentVC *techVC = [[TechProcessPaymentVC alloc]init];
[techVC setTechDelegate:self];
NSLog(@"DELEGATE == %@",techVC.techDelegate);
[self performSegueWithIdentifier:@"techProcess" sender:nil];
}
我可以看到委托已设置
Snap2Door[1765:1c703] DELEGATE == <PaymentDetailViewController: 0x9d3a360>
但是当我检查它时,TechProcessPaymentVC
我viewDidLoad
得到了DELEGATE == (null)
我想这就是我的回调方法没有被调用的原因PaymentViewController.m
。
这就是我定义委托的方式TechProcessPaymentVC.h
@protocol techProcessDelegate <NSObject>
-(void) techProcessViewControllerDismissed:(NSString *)paymentStatus;
@end
@interface TechProcessPaymentVC : UIViewController<UIWebViewDelegate>
{
id techDelegate;
}
@property (nonatomic, assign) id<techProcessDelegate> techDelegate;
这就是我试图调用的方法PaymentViewController.m
if ([[substrings objectAtIndex:0] isEqualToString:@"failure"]) {
[self.techDelegate techProcessViewControllerDismissed:@"failure"];
[self dismissViewControllerAnimated:YES completion:nil];
}