elp
elp

Reputation: 8131

How to open an UIView in fullscreen mode with a tabbar?


this is my problem.

  1. I have a tabBar application.
  2. In first tab, i have a table.
  3. On click on table it shows a modal view.
  4. To go back from modal view to first view, i use
[self presentModalViewController:nw animated:YES];

The problem is that if i click on the tabbar while is opened a modal view, it opens second view, but first view's table don't work because the modal view is still opened althoug it appear as closed.

It's a way to open modal view in fullscreen covering the tab bar?
Or also to check if modal view is closed or not from another view?


EDIT: I tried with all of this code:

 nw = [[NewsViewController alloc] initWithNibName:@"NewsViewController" bundle:nil];
 nw.modalInPopover = YES;
 nw.wantsFullScreenLayout = YES;
 nw.hidesBottomBarWhenPushed = YES;
 nw.contentSizeForViewInPopover = CGSizeMake(320, 480);
 nw.modalPresentationStyle = UIModalPresentationFullScreen;
 nw.view.frame = [[UIScreen mainScreen] applicationFrame];
 [nw.view setNeedsLayout];

but nothing!!! It wan't go in fullscreen!!

Any idea please?

thanks,
alberto

Upvotes: 2

Views: 5302

Answers (2)

elp
elp

Reputation: 8131

Resolved using notification!

When a tab change, i send a notification and close the modal controller.

- (BOOL)tabBarController:(UITabBarController *)tbController shouldSelectViewController:(UIViewController *)viewController { 
    [[NSNotificationCenter defaultCenter] postNotificationName:@"DataComplete" object:nil];
    return YES;
}

In my view classes receive a notification and dismiss the controller!

- (void)downloadDataComplete:(NSNotification *)notif {
    NSLog(@"Received Notification");

    [self dismissModalViewControllerAnimated:YES];
}

Now it's possibile to reopen a modal view also changing tab!
This is a workaround but works!

alberto.

Upvotes: 0

John Parker
John Parker

Reputation: 54445

If the view you're presenting is full screen, this should obscure the tab bar. That said, you might need to re-size the view programmatically so that it's the same size as the UIWindow.

You should be able to do something along the lines of...

[nw setFrame:[[UIScreen mainScreen] applicationFrame]];
[nw setNeedsLayout];

...to achieve this. (Sorry, I'm on a Windows box at the moment, so I can't confirm this. Hopefully someone will provide any tweaks if required.)

You should then dismiss the initial modal view via a delegate method in the originating class. (See the "Dismissing a Modal View Controller" section of Apple's View Controller Programming Guide for iOS.) The originating class would then dispose of the modal view.

Upvotes: 1

Related Questions