PageViewController overlapping NavigationItem and Toolbar - ios5

I'm currently developing an app that uses Navigation Controller for main app flow. The app includes a scene (from Storyboard) where I wish to use a PageViewController.
It's all going well, except that I'd LIKE to make the PAGE CURL EFFECT of the pages overlap the navigationItem (at the top) and the Toolbar (at the bottom). Without this, the page curl effect is much less effective because because the page curl appears to be BEHIND the navigation chrome.
Any suggestions?

you can try to reduce the frame of the pageviewcontroller:
// Establish the page view controller
CGRect appRect = [[UIScreen mainScreen] applicationFrame];
pageController = [PageViewController pageViewWithDelegate:self];
CGRect reducedFrame = CGRectMake(appRect.origin.x, appRect.origin.y, appRect.size.width, (appRect.size.height - 44)); // here is the the reduction set for the toolbar of height 44
pageController.view.frame = (CGRect){.size = reducedFrame.size};
The view is still presented in the appRect, but the pageviewcontroller is presented in the reduced frame.
Hope this helps!
Abraham

Related

First UIView not autosizing to fit iPhone 5 or iPad

I have a simple app with multiple UIViews. I've recently begun work to create a universal app out of it get the auto-sizing and rotation of views working with the iPhone 5 and iPad.
On my very first view, the view comes up as the standard 3.5" display with a white bar beneath it on the iPhone 5 (and beside it on the iPad). There is also a toolbar attached to the bottom of the view and it appears at the place where it would be on a 3.5" display. The strange thing is, when I go to another view and then return to the root view, the view is sized correctly.
I've checked my autosizing for the view - all outside and inside anchors are activated. My view mode is set to "scale to fit," and in comparison to other views, settings are the same. And the strange thing is it comes up right the second time the view is displayed.
Any thoughts?
I found my problem. It was in the didFinishLaunchingWithOptions method of the application.
I changed:
UIView *rootView = self.rootViewController.view;
CGRect rootViewFrame = rootView.frame;
rootViewFrame.origin.y +=[UIApplication sharedApplication].statusBarFrame.size.height;
to
UIView *rootView = self.rootViewController.view;
CGRect rootViewFrame = [[UIScreen mainScreen] applicationFrame];
The app was picking up the hard coded size of the view from the XIB when the view first loaded; now I just fit it within the application frame.

Custom UIView covering UITabBar on iPhone but not iPad

I'm creating a custom uiView that covers the window. It acts kinda like a decoy uiview in a navigation controller. So I had to do it this way to cover the navigation bar.... long story...
Here is how it gets setup.
self.searchPopDown.frame = CGRectMake(0, 20, self.navigationController.view.frame.size.width, self.navigationController.view.frame.size.height-20);
self.searchPopDown.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
The 20 is to compensate for the status bar.
Then I simply add the view as a subview to the app window.
//this will add the view ontop of a modalViewController and support rotation!
UIWindow* window = [UIApplication sharedApplication].keyWindow;
if (!window) {
window = [[UIApplication sharedApplication].windows objectAtIndex:0];
}
if ([[[window subviews] objectAtIndex:0] isKindOfClass:[SVProgressHUD class]]){
//There is a chance that the window will be the SVProgressHUD in this case we need to get the main window.
window = [[UIApplication sharedApplication].windows objectAtIndex:0];
}
[[[window subviews] objectAtIndex:0] addSubview:self.searchPopDown];
All of this works great and dandy. However I've noticed something strange. On the iPhone this view will end up being resized to cover the UITabBar at the bottom of my app. But on an iPad it gets resized correctly to compensate for the UITabBar. Any ideas why?
Thanks
=================
Here are some screenshots describing the issue. This is what it looks like when the view loads with the fake view onto of everything. The view shows up (as far as the user is concerned just the view and the buttons on the navbar have changed slightly. When you have searched this fake view disappears revealing the real view below with the search results. ON the ipad the fake view doesn't cover the tab bar. Why doesn't it do this on the iphone also?
==========
edit 2
Another weird thing. I'm generating log messages to get what the height of the navigation controller is. It changing by 49 depending on if I display normally or present as a modal view and there is no tab bar.
So the log says 431 should be the correct height. I go into interface builder and setup a simple pink view that's measured at 431 and it looks great :) However when I manually set the size to 431 it doesn't work. I have to set the size to 298 to get this to work correctly ... weird...
See the pink bar? It is literally 431 tall... and the log says that's what my view is.. but it's not :/
============
edit:3
I have traced this to the imagebackground with the bubble logo resizing incorrectly...
I had to check "clip subview" on the parent view that the imageview was in... fixed the problem...

How to make a view have a semi-transparent border and show the view below

Probably a bit of a newbie question, but .... I am writing an iPhone app which uses UITabBarController.
In Interface Builder I've setup the tab bar in MainWindow.xib. I have 4 tabs, and each one is set to load the xib for the appropriate UIViewController subclass. I have created the views in the xib files for each UIViewController subclass in Interface Builder.
All is working well in that I can tap each tab and it shows the view for the correct UIViewController
But what I really want is for the view for one of the UIViewController subclasses to have a semi-transparent border of approx 30px on all 4 edges, so that it shows the edges of the view behind, kind of greyed out.
IE. the first tab is the main application, and that takes up the whole screen (minus the status and tab bar areas).Tab 2 is to save, and I want it to look like a small modal window over the top of the main app.
(If I were doing this as a html web app, the terminology and technology I'd be using would be a jQuery overlay)
Does this make sense?
I've tried playing with presentModalViewController but this makes it worse in that it takes up the entire screen including the status and tab bar areas.
Any help or pointers very much appreciated
Cheers
Nathan
Your UIViewController cannot be transparent to the view below it because the iphone may unload the view below it that is not currently being shown (to save memory).
The best solution I have used is to take a picture of the current view before you push your new view controller and then use that as the background image (fake the transparency). Here's how I implemented this:
NewViewController *newView = [[NewViewController alloc] init];
shareVC.imageBackground = [Utilities getScreenshot:self.view];
[self presentModalViewController:newView animated:YES];
[newView release];
then on your newViewController do this (on viewDidLoad, viewWillAppear, etc):
[imageView setImage:imageBackground];
and here's the screenshot function
+(UIImage *)getScreenshot:(UIView *)_view {
//take a screenshow of the parent view so we can add it as a background to the modal view
if ([[UIScreen mainScreen] respondsToSelector:#selector(scale)])
UIGraphicsBeginImageContextWithOptions(_view.window.bounds.size, NO, [UIScreen mainScreen].scale);
else
UIGraphicsBeginImageContext(_view.window.bounds.size);
[_view.window.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
You then need to setup your new view with a UIImageView as the background and pick the right Alpha value for that imageView to make it appear like it's transparent.

iOS: Is is possible to make a UINavigationBar taller and "push" the other views down the screen?

Is there a way to make the "content" area of an iPhone app aware of a larger navigation bar?
Similar to these questions:
iOS: Adding a fixed image just below the navigation bar
iOS: Positioning navigation bar buttons within custom navigation bar
I've managed to use the 1st questions sample code to add a category on UINavigationBar and change its height, and added a subview where I need it, but I can't see a way to cause the UITableView (or indeed any content views) to take its height into consideration:
(The colors are only to make the different views distinguishable)
The accepted answer to the first question sets the nav bar's frame in -layoutSubviews, which is anywhere from "ewwwww" to outright wrong depending on the assumptions made by other layout code.
Instead, override -sizeThatFits: to return a more appropriate size.
I'd go about this by adjusting the tableView.frame, so something like this:
CGRect navFrame = self.navigationController.navigationBar.frame;
CGRect tableFrame = self.tableView.frame;
tableFrame.size.height = tableFrame.size.height - navFrame.size.height;
tableFrame.origin.y = navFrame.size.height; //move it down by the height covered by the navigation Bar
self.tableView.frame = tableFrame;
You could do this with your other views as well - i.e. by simply adjusting the frame.
I've not got XCode on this computer, so I've not checked the code - just written it out as an example, so please check it yourself before using it!

ipad iphone repositioning uinavigation bar, moving it down to have a logo

Does anyone know if the uinvagitionbar of a uinavigationcontroller can be moved down? I'd like to move it around 200 pixels down to have a logo on top. From my research, I understand that the navigationbar should not be subclassed and there are only two properties that should be changed, it's color and it's visibility. So is this impossible?
I tried moving it's frame, but to no avail.
I've seen other apps do it, but I'm thinking it might be a toolbar? Can the toolbar be repositioned?
Thanks
Just change the size of the frame of the navigations controller's view.
CGRect frame = navigationController.view.frame;
frame.size.height -= 200.0f;
frame.origin.y += 200.0f;
navigationController.view.frame = frame;
You can then add whatever view you'd like to the view or window that contains the navigationController's view.
There a few tricky things to consider if you plan on doing this by presenting a modal view controller, however.
You can hide the self.navigationController and put another navigation bar in the code which will move according to your frame set.
Yes the tool bar can be repositioned. Just take a control in your code and set its frame as per your requirement.
Happy Coding...