我正在尝试在我的应用中展示这个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; frame =(20 0; 748 1024); autoresize = W + H; layer =>
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 --- //
我已经完成了上面的代码,并尝试将其添加到main mainVC窗口。 它有效,但它不符合自动调整。然而,即使自动调整工作正常,这也是一种肮脏的修复,而不是我想要使用的正确解决方案。此外,它不是窗口显示自己的顺序。 与此同时,我正在使用其他(工作)演示样式之一。 但我仍然想知道解决方案..
..如果有人知道那是。
答案 0 :(得分:0)
也许问题是:
self.myViewController.SomeView = [[UIView alloc] init];
self.myViewController.SomeView.frame = self.ThisView.frame;
尝试在viewDidLoad或MyViewController的loadView中执行此操作。
-
查看编辑代码后,我仍然认为问题是您在尚未加载视图时设置框架。