I'm working on an iOS app which has a couple of non-modal views and a couple of modal views. The non-modal views have a navigation bar at the top, while the modal ones don't. The problem is that there's a common background image for both types. On the modal views, due to the lack of the navigation bar at the top, there's a small gap between the bottom of the image and the bottom of the display.
Here's the code for the opening of a non-modal display:
settingsController = [[SettingsController alloc] init];
settingsController.appState = appState;
[self.navigationController pushViewController:settingsController animated:YES];
[settingsController release];
Here's the code for the opening a modal display:
nextLevelViewController = [[[NextLevelViewController alloc] init] autorelease];
[self presentModalViewController: nextLevelViewController animated:YES];
What's the best way to have the background make up that gap at the bottom of the image?
Ok, I got it. It was just a question of modifying the view size to be a bit longer, then stretching the image to match it, in the xlb display editor.
Related
I've read a number of threads on stackoverflow about this issue, but none seemed to have a fix that worked for my most basic and straightforward case.
I'm using XCode 7.2.1 and iOS 9.2
I have a class (code shown below) that accepts a UIViewController to use as the presenter of a UINavigationController.
This code below is from ONE class, and it does both the presenting and dismissing.
Starting with screen 1 pictured below, the user taps a button in the upper left corner, which then presents the UINavigationController in screen 2. Finally, tapping the "Done" button in the upper right corner of the UINavigationController (screen 2) causes a black screen... screen 3.
Lastly, you'll notice on the black screen a little red circle with a number in it.
That is from the tab bar in screen 1 at the bottom. For some reason it stacked up all the tab bar buttons in the corner, and left a little area for them to peek out.
-(id)initWithDashboardParentViewController:(TabMapController*)mapVC propertyDelegate:(id<iRpPropertyDelegate>)propertyDelegate
{
self = [super init];
if (self)
{
mapViewController = mapVC;
thePropertyDelegate = propertyDelegate;
}
return self;
}
-(void)displaySpreadsheetOfAllSubitems
{
UIViewController *theContentController;
// Create a generic gridview view controller and initialize it with the data that will be shown.
theContentController = [[iRpGenericGridViewController alloc] initWithPropertyDelegate:propertyDelegate dashboardDataItem:spreadsheetTableData];
theContentController.edgesForExtendedLayout = UIRectEdgeNone;
// Create a navigation controller and embed the content view controller.
UINavigationController *theNavController = [[UINavigationController alloc] initWithRootViewController:theContentController];
// If a detail item was found for this section, then display it in the navigation controller.
if (theNavController)
{
// Set up the 'Done' navigation bar button.
theNavController.topViewController.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:#selector(detailDisclosureDone)];
[mapViewController presentViewController:theNavController animated:YES completion:^(void){}];
}
}
-(void)detailDisclosureDone
{
[mapViewController dismissViewControllerAnimated:NO completion:^{}];
}
Well, I did figure out that it has something to do with AutoLayout and the constraints set on my root view controller.
I made a constraint that the root view controller has to be at least a given height, instead of just saying it was 0-nearestSuperview, etc, and now I'm seeing a portion of my view.
I'm stumped :-\
I have a legacy app in the store that I'm refreshing for iOS 8/9. It was written years ago (pre-ARC) and is a universal app for iPhone and iPad. Everything is now working apart from this ...
On iPad, there is a toolbar at the top of the screen from which I present UIPopoverControllers containing a UINavigationController containing some standard UITableViewController type screens you can drill down into.
In Portrait (and Portrait Upside Down) everything works as expected.
In Landscape however, pressing 'Back' (the standard back not a custom one) causes weird animations - the outgoing controller jumps outside the popover and rapidly slides offscreen (the direction being governed by which orientation the device is in) while the incoming controller simply appears instantly as soon as the outgoing controller jumps outside the popover. I had to use slow animations to determine this as at full speed it just looks like a huge glitch.
There's a short 20 second movie showing the defect here; Note what happens when tapping 'Locations' at 14 seconds in.
If, instead of a UIPopover, I present the VC stack as a form sheet, everything works as expected regardless of orientation. I've also tried the newer UIPopoverPresentationController and experienced the SAME problem, which surprised me a little.
This happens on both of the popovers I'm presenting (one from left of toolbar, one from right of toolbar) and they both have very different internals. The only common factor is that they have a UINavigationController inside a UIPopover.
I've used the view debugger to inspect the view hierarchy, but nothing seems out of the ordinary and I can't capture the view during the glitch no matter how slow I run the simulator so I suspect I'm seeing an internal issue with the popover or navigation controller.
Has anyone seen anything similar? I see this both on-device (iOS 8.4) and in Simulators for iOS 8 and 9.
For context, this project has no storyboards, rarely uses xibs and generally constructs the UI in code within loadView - it really is an old application...
Thanks for any pointers. Not sure how much any code will help here, but here's the presentation of the popover concerned;
LocationsViewController* locationsvc = [[LocationsViewController alloc] init];
UINavigationController *localNavigationController = [[UINavigationController alloc] initWithRootViewController:locationsvc];
localNavigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
[locationsvc release];
UIPopoverController* aPopover = [[UIPopoverController alloc] initWithContentViewController:localNavigationController];
aPopover.delegate = self;
aPopover.backgroundColor = [UIColor colorWithWhite:0 alpha:0.9];
self.locationPopoverController = aPopover;
[aPopover release];
[localNavigationController release];
[locationPopoverController presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
I get the same defect with the following, new flavour code;
UINavigationController *destNav = [[UINavigationController alloc] initWithRootViewController:locationsvc];
locationsvc.preferredContentSize = CGSizeMake(320,280);
UIPopoverPresentationController *newPresentationController;
destNav.modalPresentationStyle = UIModalPresentationPopover;
newPresentationController = destNav.popoverPresentationController;
newPresentationController.barButtonItem = sender;
destNav.navigationBarHidden = NO;
[self presentViewController:destNav animated:YES completion:nil];
And the same problem shows when I use UIModalPresentationPageSheet but NOT when I use UIModalPresentationFormSheet.
I had the same issue. The issue was fixed after I added support of landscape orientation to view controllers inside the navigation controller.
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll;
}
I am looking for a way to implement this kind of popover.
Are there basic iOS commands to generate this style instead of the usual Arrow + Border popover that we see in XCode? Or is there an API to do this kind of thing.
The popover is coming up from the bottom of the screen, just like in the App Store animation sometimes.
Thank you
What you want to do is create a custom UIVIewController with the modal presentation style set to UIModalPresentationFormSheet:
YourCustomViewController *customVC = [[YourCustomViewController alloc] initWithNib:#"YourCustomViewController" bundle:nil];
customVC.modalPresentationStyle = UIModalPresentationFormSheet;
[self self presentViewController:customVC animated:YES completion:nil];
You will also have to create a toolbar and format it correctly with a "close" or "done" button that will dismiss the view controller
I use UINavigationController inside UITabBarController and one of the screens in my navigationcontroller is a UIImageView. When I want to show that image full screen I have to hide the navigation bar and tab bar. I'm able to hide the navigation bar correctly but when I hide the tab bar, it leaves 50px of white space. Any suggestion?
Thank you for all
I have found the best solution to my problem .
MyImageViewController.hidesBottomBarWhenPushed = YES ;
[self.navigationController pushViewController:MyImageViewController animated:YES];
It gave me the response I wanted .
Thank you for your share
I think you can show it on model view controller.
Put modelviewcontroller over tabbarcontroller.
FullImageView*objFullImageView = [[FullImageView alloc] initWithNibName:#"FullImageView" bundle:nil];
objFullImageView.image = OriginalImage;
UINavigationController *tempNav = [[[UINavigationController alloc] initWithRootViewController:objFullImageView] autorelease];
[objFullImageView release];
self.tabBarCtrl.modalPresentationStyle = UIModalPresentationPageSheet;
[self.tabBarCtrl presentModalViewController:tempNav animated:YES];
FullImageView.h
{
UIImage *image;
}
#property(nonatomic, retain) UIImage *image;
FullImageView.m
#synthesize image;
viewDidLoad /ViewWillApper
{
//Set image in your UIImageView
}
I solved this problem by changing constraints.
I had a view in my tabbar viewController whose bottom constraint was given (=0) from Safe Area.bootom. This was causing white space at the bottom. Changing this constraint to (=0) from Superview.bottom solved my proble.
You can increase the height of your image view frame.
After hours of research, this thread resolved my blank space issue when hidding the tabbar: hiding TabBar when rotating iPhone device to landscape
It's been quite a long time since the original post, but I thought I could jump in and add my thoughts.
Another option would be to set the option Hide bottom bar on push directly within the Storyboard for all those controllers which are pushed within a navigation controller inside a tabbar controller. This works within iOS7 simulator/targets as well, both at 3.5" and 4".
Apple says:
UIModalPresentationFormSheet
The width and height of the presented view are smaller than those of the screen and the view is centered on the screen. If the device is in a landscape orientation and the keyboard is visible, the position of the view is adjusted upward so that the view remains visible. All uncovered areas are dimmed to prevent the user from interacting with them.
But my view doesn't move up when the keyboard is visible. I basically want to present a textview modally above the keyboard so the user can enter text and then hit send (in a nav bar button on the presented view.)
My presenting view is a UISplitViewController (not one of its children) and I'm presenting UINavigationController who's top view controller is basically a UITextView. Rotation works, but the presented view is overlapped by the keyboard in both orientations.
I found some questions asking how to resize the presented view in this case, which is nice, but I don't want to have to make assumptions by resizing manually in the presenter or in the presented view. It seems like it should just pick a decent (undocumented) size just move it up automatically when the keyboard shows.
My presenting code looks like this:
MyViewController *vc = [[MyViewController alloc] init];
UINavigationController *nav = [[[UINavigationController alloc] initWithRootViewController:vc] autorelease];
nav.modalPresentationStyle = UIModalPresentationFormSheet;
[self.splitViewController presentModalViewController:nav animated:YES];
As I was finishing up my question, I realized I was calling becomeFirstResponder on my UITextView in viewWillAppear. If you change it to viewDidAppear it will work, which makes sense.