私はいくつかのビューを作成するフレームワークを持っています.フレームワークを使用するアプリはそれからメソッドを呼び出して現在のビューコントローラーを渡します.フレームワークはpresentModalViewControllerを呼び出してビューを表示します.
iOS 6.1 SDK では問題なく動作していましたが、Xcode 5 および iOS 7 SDK に更新すると、モーダル ビューが表示されなくなり、代わりに空白の画面が表示されます。
編集
いくつかのコードを次に示します。
フレームワークは「testityi」と呼ばれます
testityi.m
#import "TestViewController.h"
@implementation testitiy
- (NSString*) sayHi : (NSString*) name {
return [NSString stringWithFormat:@"Hello %@", name];
}
- (void) displayView:(UIViewController *)parentController {
TestViewController* controller = [[TestViewController alloc] init];
[parentController presentViewController:controller animated:YES completion:nil];
}
TestViewController は、「フレームワークからのビュー」というラベルが付いた単純なビューです。
フレームワーク自体は正常に動作し、sayHi メソッドの呼び出しは正常に動作します。
サード パーティ製アプリには、sayHi メソッドを呼び出してから displayView メソッドを呼び出すラベルとボタンを含むビューがあり、ビュー コントローラー コードは次のとおりです。
MainViewController.m
- (IBAction)buttonPressed:(id)sender {
testitiy* framework = [[testitiy alloc] init];
NSString* msg = [NSString stringWithFormat:@"Calling sayHi method on framework...\n result: %@", [framework sayHi:@"John"]];
UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"sayHi method call" message:msg delegate:self cancelButtonTitle:@"Ok, show me the view" otherButtonTitles:nil, nil];
[alert show];
}
-(void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if(buttonIndex == [alertView cancelButtonIndex]) {
testitiy* framework = [[testitiy alloc] init];
[framework displayView:self];
}
}
アラートボタンのアクションも正しく機能しています。前に NSLog を追加して動作しました。
アラート ボタンをクリックすると、ビューが表示されますが、「フレームワークからのビュー」というラベルが表示される代わりに、空白の画面が表示されます。
コードはGithubで見ることができます
編集2
わかった...フレームワークからViewControllerでinitWithBundleを呼び出していなかったので、次を呼び出すカスタムinitメソッドを追加しました。
フレームワーク: TestViewController.m
+ (NSBundle *)frameworkBundle {
static NSBundle* frameworkBundle = nil;
static dispatch_once_t predicate;
dispatch_once(&predicate, ^{
NSString* mainBundlePath = [[NSBundle mainBundle] resourcePath];
NSString* frameworkBundlePath = [mainBundlePath stringByAppendingPathComponent:@"testity.bundle"];
frameworkBundle = [NSBundle bundleWithPath:frameworkBundlePath];
});
return frameworkBundle;
}
- (id) initWithFramework {
NSBundle* bundle = [[self class] frameworkBundle];
self = [super initWithNibName:@"TestViewController" bundle: bundle];
return self;
}
そしてtestitiy.mを変更しました
- (void) displayView:(UIViewController *)parentController {
TestViewController* controller = [[TestViewController alloc] initWithFramework];
[parentController presentViewController:controller animated:YES completion:nil];
//[parentController.navigationController pushViewController:controller animated:YES];
}
そして今、その作業...
これが他の誰かに役立つことを願っていますが、それは私のばかげた間違いだったと思います。ご迷惑をおかけして申し訳ありません。お時間をいただきありがとうございます。