Modal View Controller (2番目) から Modal View Controller (1番目) を読み込もうとしています。複雑に聞こえますが、おそらくそうではありません。
最初のコントローラーは、実際には .m ファイルの loadView メソッドで初期化される UIWebView です。
- (void)loadView {
// Initialize webview and add as a subview to LandscapeController's view
myWebView = [[[UIWebView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]] autorelease];
//CGRect forceframe = CGRectMake(0, 0, 480, 320);
//myWebView = [[[UIWebView alloc] initWithFrame:forceframe] autorelease];
myWebView.scalesPageToFit = YES;
myWebView.autoresizesSubviews = YES;
myWebView.autoresizingMask = (UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
myWebView.delegate = self;
self.view = myWebView;
}
次にviewDidLoadで:
- (void)viewDidLoad {
[super viewDidLoad];
// Load HTML file as an NSURL request
[self.myWebView loadHTMLString:updated_html baseURL:nil];
// Invoke the covering modal view on condition
if (some_condition) {
landscapeCoverController = [[UIViewController alloc] initWithNibName:@"LandscapeCoverController" bundle:[NSBundle mainBundle]];
[self presentModalViewController:landscapeCoverController animated:YES];
[landscapeCoverController release];
}
意図した 2 番目の Modal View Controller (landscapeCoverController) は、IB で設定した NIB で初期化されます。
私の意図した目的は、条件付きで UIWebView を「LandscapeCoverController」ビューで覆い隠すことです。これには、いくつかのボタンと対話性があり、2番目のモーダル ビューが閉じられます。
ランドスケープカバーコントローラーが読み込まれないのはなぜですか? どんな考えでも大歓迎です!
また...最初のモーダル ビュー コントローラー (LandscapeViewController) .h は次のようになります。
@class LandscapeCoverController;
@interface LandscapeViewController : UIViewController <UIWebViewDelegate> {
UIWebView *myWebView;
LandscapeViewController *landscapeCoverController;
}
@property (nonatomic, retain) UIWebView *myWebView;
@property (nonatomic, retain) LandscapeViewController *landscapeCoverController; // Modal view controller
そして... 2番目のモーダルビューコントローラー(landscapeCoverController)viewDidLoadは何もしません:
// NIB initialized in LandscapeViewController.m viewDidLoad:
- (void)viewDidLoad {
[super viewDidLoad];
}
私が思うように
landscapeCoverController = [[UIViewController alloc] initWithNibName:@"LandscapeCoverController" bundle:[NSBundle mainBundle]];
[self presentModalViewController:landscapeCoverController animated:YES];
[landscapeCoverController release];
ステートメントは、コントローラーの初期化とロードを処理する必要があります...