我有一个tabcontroller,它有两个段。其中一个是 UserInfo,另一个是 UserAvatar。一旦用户输入他的信息,然后单击完成按钮并转到主视图,或者用户也可以选择他的个人资料头像然后单击单击按钮然后可以转到主视图。但是,即使我在调试模式下运行代码,它也会运行到完成按钮,但在我的用户信息视图中,delegeta 方法没有被触发!
在我的 Main 头文件中,我声明我的协议如下:
@protocol MyUserInfoAvatarViewControllerDelegate <NSObject>
@required
-(void)userInfoEditingDone:(id)sender;
@end
@protocol MyUserInfoSettingsViewControllerDelegate <NSObject>
@required
-(void)userInfoEditingDone:(id)sender;
@end
在我的 main.m 文件中,我的委托方法
- (void)userInfoEditingDone:(id)sender {
NSLog(@"Hello");
}
MyUserInfoAvatarViewController.h
#import <UIKit/UIKit.h>
#import "NEATMainViewController.h"
@interface UserInfoAvatarViewController : UIViewController <ThumbImageViewDelegate > {
id __unsafe_unretained flipDelegate;
}
@property (nonatomic,unsafe_unretained) id <MyUserInfoAvatarViewControllerDelegate>
翻转委托;在以下响应中 MyUserInfoAvatarViewController.m
- (IBAction)doneButtonPressed:(id)sender {
// Tell the root view to flip back over to the main view
[self.flipDelegate userInfoEditingDone:self];
}
MyUserInfoSettingsViewController.h
#import <UIKit/UIKit.h>
#import "NEATMainViewController.h"
@interface UserInfoSettingsViewController : UIViewController {
id __unsafe_unretained flipDelegate;
}
@property (nonatomic,unsafe_unretained) id <MyUserInfoSettingsViewControllerDelegate> flipDelegate;
在下面没有调用我的委托方法.. MyUserInfoSettingsViewController.m
- (void)viewDidLoad {
[super viewDidLoad];
UIBarButtonItem *btn = [[UIBarButtonItem alloc] initWithTitle:@"Done" style:UIBarButtonItemStyleBordered target:self action:@selector(done:)];
self.navigationItem.rightBarButtonItem = btn;
}
- (void)done:(id)sender {
// Tell the root view to flip back over to the main view
[self.flipDelegate userInfoEditingDone:self];
}