This question already has answers here:
Status bar and navigation bar issue in IOS7
(11 answers)
Closed 8 years ago.
Hi status bar overlapping with navigation bar.though i am able to display correctly when i load screen when i rotate navigation bar and status bar overlaps i tried to set all these properties
if([[[UIDevice currentDevice] systemVersion]floatValue ] >= 7.0)
{
self.extendedLayoutIncludesOpaqueBars = NO;
self.automaticallyAdjustsScrollViewInsets = NO;
self.navigationController.navigationBar.translucent=NO;
self.edgesForExtendedLayout = UIRectEdgeAll;
}
If you're not using storyboard, then you can use this code in your AppDelegate.m in did finishlaunching:
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7)
{
[application setStatusBarStyle:UIStatusBarStyleLightContent];
self.window.clipsToBounds =YES;
self.window.frame = CGRectMake(0,20,self.window.frame.size.width,self.window.frame.size.height-20);
}
Related
There are multiple questions about "switching from iOS 6 Status Bar to iOS 7", but I would like to ask the opposite.
My question is: How can I make iOS 6 screen frame slip under the status bar? I tried to move the self.window.frame and self.window.bounds in App Delegate, it is okay to shift up under the status bar, but the bottom will leave a 20 ~ 40px black line.
Here is the codes:
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 6 && [[[UIDevice currentDevice] systemVersion] floatValue] < 7) {
[application setStatusBarStyle:UIStatusBarStyleLightContent];
self.window.clipsToBounds = YES;
self.window.frame = CGRectMake(0, -20, self.window.frame.size.width, self.window.frame.size.height + 40);
self.window.bounds = CGRectMake(0, -40, self.window.frame.size.width, self.window.frame.size.height + 80);
}
I tried many values, but none fits my needs. What did I miss? I think I'm close.
Here is the mock screenshot I want to achieve ( I know the signal status of iOS 6 is not like this. Just to show the idea )
Note: only needs to support iOS 6+
My final solution is to remove the codes in App Delegate, and add IBOutlet to the header image of each page.
Then, in the method - (void)viewDidLayoutSubviews:
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(#"7")) {
[iv_header setFrame:CGRectMake(0, 0, 320, 60)];
}
where the if-case is defined as:
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
In the ios7, the status bar is changed, it overlaps on my view.
I use this method to prevent this.
if([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)
{
self.automaticallyAdjustsScrollViewInsets = NO;
self.extendedLayoutIncludesOpaqueBars = YES;
self.edgesForExtendedLayout = UIRectEdgeNone;
}
It works when I have a navigationbar, but I set the navigationbar hidden, the problem comes again.
Add to your .plist file row:
View controller-based status bar appearance = NO
My app's view is overlapped with status bar and navigationBar in ios7 device so I tried lots of solutions
uncheck 'under top bars' property in storyboard
self.edgesForExtendedLayout = UIRectEdgeNone;
set delta y to -20 in storyboard...
but none of these worked.
My last trial was adding these lines to appdelegate's didFinishLaunchingWithOptions
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
application.statusBarStyle = UIStatusBarStyleLightContent;
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].applicationFrame];
self.window.clipsToBounds =YES;
} else {
self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
}
It works quite well when navigation bar is hidden but when nagivigation is not hidden,
navigationbar's frame is (0, 20, 320, 44) not (0, 0, 320, 44)
So navigationBar's height seems to be 64..
why is this? Hope someone explains me!
Thanks is advance :)
For a better explanation of the differences please see this transition guide (link).
Make sure you set this in viewWillAppear:
self.navigationController.navigationBar.translucent = NO;
self.edgesForExtendedLayout = UIRectEdgeNone;
To avoid the overlapping with the UINavigationBar, you must set its translucent property to NO.
As for the status bar, you have to manually set it by specifying its style and then reposition the whole window's frame. I would add on top of that an iOS 7 condition to make sure that only happen with users running iOS 7.
if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1) {
[application setStatusBarStyle:UIStatusBarStyleLightContent];
self.window.clipsToBounds =YES;
self.window.frame = CGRectMake(0, 20, self.window.frame.size.width, self.window.frame.size.height - 20);
}
The new iPhone screen has screwed up my app. On the iPhone 3.5 inch screen, everything is out of place. I have two different views in the same storyboard I have tried out detecting and trying to switch storyboard views but nothing has worked yet. Could I get some code on how to switch to the right view at the launch? Do I place this code in my main view controller, or do I put this in my app delegate?
CGRect screenBounds = [[UIScreen mainScreen] bounds];
if (screenBounds.size.height == 568) {
// code for 4-inch screen
} else {
// code for 3.5-inch screen
}
What my views look like http://www.fileden.com/files/2012/6/18/3317719/screenshot7.jpg
Initialize this in the app delegate for the app in "didFinishLaunchingWithOptions:" and then call the right NIB or Storyboard for the device/screen size. Create a different Storyboard for each and if you wish use auto layout for iOS 6 in your Storyboard. Start your if Statement with something like this:
if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone){
if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone && [UIScreen mainScreen].bounds.size.height == 568.0){
//iPhone 5 storyboard
}
else {
// other storyboard here
}
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
iPhone orientation
Depending on what orientation the iPad is in, I need to either set the table view's background or remove it because it doesn't work with the popover.
I tried this but no luck:
if( [UIApplication sharedApplication].statusBarOrientation == UIInterfaceOrientationLandscapeLeft ){
self.navigationController.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"background.png"]];
self.tableView.backgroundColor = [UIColor clearColor];
NSLog(#"test");
Maybe there is a better way? To see if table is master or popover, then set background?
There are several ways to achieve what you want, more or less:
UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation];
A more hack-ish method would be to check the width of the status bar.
If you go with option 1, then you can check the orientation like so:
switch (orientation) {
case UIInterfaceOrientationPortrait:
// Do something.
break;
case UIInterfaceOrientationPortraitUpsideDown:
// Do something.
break;
case UIInterfaceOrientationLandscapeLeft:
// Do something.
break;
case UIInterfaceOrientationLandscapeRight:
// Do something.
break;
}
EDIT: To get your application to automatically rotate, you can do this:
- (BOOL)willAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if ((interfaceOrientation == UIDeviceOrientationLandscapeRight)) NSLog(#"Right");
if ((interfaceOrientation == UIDeviceOrientationLandscapeLeft)) NSLog(#"Left");
if ((interfaceOrientation == UIDeviceOrientationPortrait)) NSLog(#"Up");
if ((interfaceOrientation == UIDeviceOrientationPortraitUpsideDown)) NSLog(#"Down");
return YES;
}
UIInterfaceOrientation orientation = [UIDevice currentDevice].orientation;