我正在尝试在我的应用程序中展示这个 modalViewController,它需要是全屏的。
这就是我调用 ModalViewController 的方式。
myViewController = [[MyViewController alloc] init];
//self.myViewController.SomeView = [[UIView alloc] init];
//self.myViewController.SomeView.frame = self.ThisView.frame;
//self.myViewController.backButtonEnabled = NO;
//self.myViewController.dismissDelegate = self;
//[self.myViewController doLoadShizzle]; //do this to load view and stuffs as well
//all commented to try to make the edit construction work
UINavigationController *navController = [[UINavigationController alloc]
initWithRootViewController:self.myViewController];
navController.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentModalViewController:navController animated:YES];
[self.myViewController release];
[navController release];
navController.modalPresentationStyle 适用于除全屏模式之外的所有内容。我已经在 ViewDidLoad 中记录了 modalview 的 self.view 并且它具有正确的尺寸(包括对状态栏的调整)
NSLog (modalviewcontroller.view) => < UIView: 0x7d173a0; 帧 = (20 0; 748 1024); 自动调整大小 = W+H;层=>
NSLog (modalviewcontroller.SomeView => < UIView: 0x7d154a0; frame = (0 0; 1024 660); layer = >
我在这里做错了(显然),但我似乎无法弄清楚它是什么。我一直在寻找解决方法,但到目前为止,没有一个选项是答案。如果有人知道这里的问题是什么,我非常想知道。
提前致谢。
//---编辑---//
好的,现在我构建了这个原型,并且我确认这段代码可以按照我的意愿工作。然而,我似乎无法在我更大的架构中实现同样的东西。
--------.h (mainVC)
#import <UIKit/UIKit.h>
#import "ModalFullScreenShizzle.h"
@interface ModalViewControllerFullScreenTry2ViewController : UIViewController <ModalViewDelegate>
{
ModalFullScreenShizzle *fullscreenShizzle;
}
@property (nonatomic,retain) ModalFullScreenShizzle *fullscreenShizzle;
-(void)gotoFullscreenModal;
@end
------------.m (mainVC)
@implementation ModalViewControllerFullScreenTry2ViewController
@synthesize fullscreenShizzle;
- (void)viewDidLoad
{
[super viewDidLoad];
self.view.backgroundColor = [UIColor yellowColor];
UIButton *fullscreenActivate = [[UIButton alloc] initWithFrame:CGRectMake(100, 100, 200, 200)];
fullscreenActivate.backgroundColor = [UIColor greenColor];
[fullscreenActivate addTarget:self action:@selector(gotoFullscreenModal) forControlEvents:UIControlEventTouchUpInside];
[fullscreenActivate setTitle:@"Full Screen ACTIVATE!!!!!!1111one" forState:UIControlStateNormal];
[self.view addSubview:fullscreenActivate];
}
-(void)gotoFullscreenModal
{
self.fullscreenShizzle = [[ModalFullScreenShizzle alloc] init];
self.fullscreenShizzle.theScreen.frame = self.view.frame;
// self.fullscreenShizzle.dismissDelegate = self;
UINavigationController *navController = [[UINavigationController alloc]
initWithRootViewController:self.fullscreenShizzle];
navController.modalPresentationStyle = UIModalPresentationFullScreen;
[self presentModalViewController:navController animated:YES];
// [self.fullscreenShizzle release];
// [navController release];
}
-(void)didDismissModalView
{
[self dismissModalViewControllerAnimated:YES];
}
------------.h (modalVC)
#import <UIKit/UIKit.h>
@protocol ModalViewDelegate <NSObject>
- (void)didDismissModalView;
@end
@interface ModalFullScreenShizzle : UIViewController
{
UIView *theScreen;
id<ModalViewDelegate> dismissDelegate;
}
@property (nonatomic, retain) UIView *theScreen;
@property (nonatomic, assign) id<ModalViewDelegate> dismissDelegate;
@end
--------------.m (modalVC)
#import "ModalFullScreenShizzle.h"
@implementation ModalFullScreenShizzle
@synthesize theScreen;
- (void)loadView
{
[super loadView];
self.view.frame = theScreen.frame;
self.view.backgroundColor = [UIColor blueColor];
}
//---编辑 2 ---//
我已经完成了上面的代码并尝试将它添加到主 mainVC 窗口。它可以工作,但不符合自动调整大小。然而,即使自动调整大小工作正常,这(有点)是一个肮脏的修复,而不是我想使用的正确解决方案。这也不是窗口显示自己的顺序。与此同时,我正在使用其他(工作)演示风格之一。但我仍然想知道解决方案..
..如果有人知道那是。