// userprofileform.h(viewcontroller)
@class UserProfileForm;
@protocol UserProfileFormDelegate <NSObject>
- (void) UserProfileFormDelegateReload: (UserProfileForm *) sender;
@end
@interface UserProfileForm : OTSFormViewController <UIActionSheetDelegate>
@property(nonatomic,assign) id <UserProfileFormDelegate> delegate;
@end
//userprofileform.m
#import "UserProfileForm.h"
@implementation UserProfileForm
- (void)endFlow:(id)sender {
[self.delegate UserProfileFormDelegateReload:self];
[self.navigationController popViewControllerAnimated:YES];
}
//shopprofilecontroller.h
#import "UserProfileForm.h"
@interface ShopProfileController : OTSViewController <UserProfileFormDelegate>
@end
//shoprofilecontroller.m
@implementation ShopProfileController
- (void)viewDidLoad
{
[super viewDidLoad];
self.navigationItem.title = @"Business";
UserProfileForm * userProfileForm = [[UserProfileForm alloc] init];
userProfileForm.delegate = self;
}
-(void)UserProfileFormDelegateReload:(UserProfileForm *)sender{
NSLog(@"delegates fired");
}
但是在弹出UserProfileForm时不会调用委托方法。
我不知道为什么不开火。我已经尝试过NSNotifications,但也没有触发。
最佳答案
我刚刚尝试了您的代码,但效果很好。
我唯一更改的是在viewDidLoad()
的ShopProfileController
末尾放置以下行:
[userProfileForm endFlow:self];
因此,您的委托实现应正确。
在您的
endFlow()
方法中设置一个断点,我敢打赌它不会被调用。