我认为您应该遵循标准 SDK 中的MFMailComposeViewController和其他几个模式。这意味着您的框架将提供作为 UIViewController 子类的公共类。
#import <MyFramework/MyFrameworkViewController.h>
@interface CustomerViewController : UIViewController <MyFrameworkViewControllerDelegate>
@end
- (IBAction)pressedShowFrameworkVC:(id)sender {
MyFrameworkViewController *frameworkVC = [[MyFrameworkViewController alloc] init];
// your framework init can init from your bundle's nib
frameworkVC.delegate = self;
[self presentViewController:frameworkVC animated:YES completion:^{}];
}
当用户完成它时,您的框架 vc 会自行关闭。
// MyFrameworkViewController.m
[self dismissViewControllerAnimated:YES completion^{
[self.delegate frameworkVC:self didFinishWithStuff:@"Done"];
}];
您的客户实施此...
- (void)frameworkVC:(MyFrameworkViewController *)frameworkVC didFinishWithStuff:(NSString *)objectDescribingCompletionState {
}
编辑- 假设您的框架还需要为客户应用程序做一些与视图控制器无关的工作。它仍然可以提供 NSObject 的子类(或 NSURLConnection 或其他)作为另一个公共类。
// CustomerViewController.m
#import <MyFramework/MyFrameworkWorkerBee.h>
- (IBAction)pressedMakeMyFrameworkDoSomethingUseful:(id)sender {
MyFrameworkWorkerBee *workerBee = [[MyFrameworkWorkerBee alloc] init];
[workerBee fetchStuffFromTheWebWithCompletion:^(id result) {
// now present results
MyFrameworkViewController *frameworkVC = [[MyFrameworkViewController alloc] init];
frameworkVC.delegate = self;
frameworkVC.resultsToPresent = results;
[self presentViewController:frameworkVC animated:YES completion:^{}];
}];
}