0

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

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];

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; frame = (20 0; 748 1024); autoresize = W+H; 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.

Thanks in advance.

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

#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];
}

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

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.

Totumus Maximus
  • 7,543
  • 6
  • 45
  • 69

1 Answers1

0

Maybe the problem is :

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

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

--

EDIT

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.

Jonathan Naguin
  • 14,526
  • 6
  • 46
  • 75
  • Ive tried allocing the view of my modalviewcontroller in the loadview and viewdidload now. Ive passed the parent frame to the modalview and made the modalviewcontroller.SomeView = parentFrame. Its still not working. The following is what i see: Im working in landscape mode only and auto rotate is on (as it should). Still when i press the button that pops the modalviewcontroller it rotates the parentview sideways (within his own frame) and then that view becomes black and doesnt show a thing. – Totumus Maximus Sep 30 '11 at 09:54
  • don't use the parent's frame! use bounds instead (includes rotation correction) and implement the shouldAutorotateToInterfaceOrientaiton method. does presenting the view controller without a navigation controller work? – Martin Ullrich Sep 30 '11 at 10:05
  • The autorotate isnt the issue here. it has been handled in a superclass of modalviewcontroller (it worked for other classes the same way as I was implemending it here) "does presenting the view controller without a navigation controller work?" -> What do u mean with this? Does my view shows correctly when I show it as a normal UIViewController? In that case yes but it gets a custom navbar which is used for all normal other views. Second it doesnt fill the whole screen but parts of it (it needs to cover both bottom and navbar) it only fills the screen allocated by the class calling the modal – Totumus Maximus Sep 30 '11 at 10:19
  • I commented out all the frame settings and only setted them inside the loadview (also tried in the viewdidappear to the same effect) of the modalVC. – Totumus Maximus Sep 30 '11 at 12:17