1
我有一個UIViewController幾個塞格斯深,當使用完畢後,應unwind
並帶他們回DashboardViewController。平倉防止委託被稱爲
我創建了儀表板的unwindToDashboard
方法和鉤住我的FinishViewController
一個按鈕到Exit
。所以,當它的點擊將啓動展開動作。
這工作正常。
但我需要將數據傳回從FinishViewController儀表板。
因此,我爲FinishViewController
創建了一個代理ProcessDataDelegate
,並使儀表板符合它。
然而,在儀表板的委託方法是不調用。
誰能告訴我,我做了什麼錯?
DashboardViewController.m
#import "FinishViewController.h"
@interface DashboardViewController() <ProcessDataDelegate>{
FinishViewController *fm;
}
@end
@implementation DashboardViewController
- (void)viewDidLoad {
[super viewDidLoad];
if(!fm){
fm = [[FinishViewController alloc] init];
}
fm.delegate = self;
}
- (IBAction)unwindToDashboard:(UIStoryboardSegue *)unwindSegue {
//empty
}
#pragma mark PROTOCOL METHODS
-(void) didFinishWithResults:(NSDictionary*) dictionary{
NSLog(@"Dashboard method called didFinishWithResults");
}
@end
FinishViewController.h
@class FinishViewController;
@protocol ProcessDataDelegate <NSObject>
@required
- (void) didFinishWithResults: (NSDictionary*)dictionary;
@end
@interface FinishViewController : UIViewController
@property (nonatomic, weak) id <ProcessDataDelegate> delegate;
@end
FinishViewController.m
@interface FinishViewController()
@end
@implementation FinishViewController
- (void)viewDidLoad {
[super viewDidLoad];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
NSLog(@"fired via the button to the exit--- Segue: %@", [segue identifier]);
[delegate didFinishWithResults:nil ];
}
@end
如果您正在使用塞格斯和故事情節,你不能實例化一個的viewController與[頁頭] INIT]你需要得到您的目的地視圖控制器在賽格瑞方法準備並通過委託有 –
如果有什麼需要的SEGUE爲4個或5塞格斯嗎?這就是我使用展開功能的原因。 –
但只有一個去finishViewController不是嗎?,並有一個標識符? –