presentModalViewController全屏模式问题 [英] presentModalViewController fullscreenmode issue

查看:150
本文介绍了presentModalViewController全屏模式问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的应用程序中展示此modalViewController,它必须为全屏显示.

I'm trying to present this modalViewController in my app and it needs to be fullscreen.

这就是我调用ModalViewController的方式.

This is how I call up the 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中记录了模态视图的self.view,它具有正确的尺寸(包括对状态栏的调整)

The navController.modalPresentationStyle works for everything besides the full screen mode. I've logged the self.view of the modalview in the ViewDidLoad and it has the right dimensions (including the adjustments to the statusbar)

NSLog(modalviewcontroller.view)=>< UIView:0x7d173a0;框架=(20 0; 748 1024);自动调整大小= W + H;层=>

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 =>

NSLog (modalviewcontroller.SomeView => < UIView: 0x7d154a0; frame = (0 0; 1024 660); layer = >

我在这里做错了(显然),但是我似乎无法弄清楚它是什么. 我一直在寻找解决方法,但到目前为止,所有选项都没有答案. 如果有人对这里的问题有所了解,我非常想知道.

Im doing something wrong here (obviously), but I can't seem to figure out what it is. I've been searching for stuff as workaround but none of the options have been the answer thus far. If anyone has a clue of what the issue is here, I would very much like to know.

谢谢.

//--- 编辑 ---//

//---EDIT---//

好,现在我构建了这个原型,并确认该代码可以按我的意愿工作.但是我似乎无法在较大的体系结构中实现相同的功能.

Ok, now I build this prototype and I confirmed that this code is working as I want it to. Yet I can't seem to implement the very same thing in my larger architecture.

--------.h(mainVC)

--------.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)

-----------.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)

-----------.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)

--------------.m (modalVC)

#import "ModalFullScreenShizzle.h"

@implementation ModalFullScreenShizzle

@synthesize theScreen;

- (void)loadView
{
    [super loadView];
    self.view.frame = theScreen.frame;
    self.view.backgroundColor = [UIColor blueColor];
}

//--- 编辑2 ---//

//---EDIT 2---//

我已经完成了上面的代码,并尝试将其添加到mainVC主窗口中. 它可以工作,但是不符合自动调整大小.即使自动调整大小正常,这还是一个肮脏的修复,而不是我想使用的适当解决方案.同样,这也不是窗口显示自身的顺序. 同时,我正在使用其他一种(有效的)演示样式. 但是我仍然想知道解决方案..

I've done the code above this and tried to add it to main mainVC window. It works but it's not conforming to the autoresizing. Yet even if the autoresizing works properly this is (kinda) a dirty fix and not a proper solution that I'd like to use. Also it's not the the order of which windows show themselves. In the meantime I'm using one of the other (working) presentation styles. But I would still like to know the solution..

..如果有人知道的话.

..if anyone knows that is.

推荐答案

也许问题是:

 self.myViewController.SomeView = [[UIView alloc] init];
 self.myViewController.SomeView.frame = self.ThisView.frame;

尝试在MyViewController的viewDidLoad或loadView中执行此操作.

Try to do this inside the viewDidLoad or loadView of the MyViewController.

-

查看完您的编辑代码后,我仍然认为问题在于您尚未设置视图时正在设置Frame.

After look your edit code, I am still think that the problem is that you are setting the Frame when the view is not loaded yet.

这篇关于presentModalViewController全屏模式问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆