UINavigationBar aspect changed on iOS 9 - ios

I have realised my app is showing a different aspect on the navigation bar for iOS 9.
My app is landscape view always, and I am using a custom height:
- (CGSize)sizeThatFits:(CGSize)size {
[super sizeThatFits:size];
CGFloat screenWidth = [UIScreen mainScreen].bounds.size.width;
CGSize newSize = CGSizeMake(screenWidth, VFSNavigationBarHeight);
return newSize;
}
It looks perfect on iOS 8 and iOS 7, but the content is not vertical aligned on iOS 9.
This is how it looks on iOS 7 and 8.
And this is exactly the same code running on iOS 9.
As you can see iOS 9 is moving down the content of the navigation bar, and I'm not sure why. Any idea? Thanks

Related

Screen hight with (UIScreen) is fine in iPad but wrong in iPhone

I am developing a game where a background is moving at the back. I sat the background hight using the below code. It is working fine with iPads but with iPhones it is not taking the proper hight of the screen; instead it is in the middle of the screen with almost half the hight of the screen! The application is only working in portrait orientation. This is for xCode 8 & SWIFT 3
Please check below the code I am using for the background
hight:
let screenSize: CGRect = UIScreen.main.fixedCoordinateSpace.bounds
background1.size.height = screenSize.height
Thanks in advance
I have resolved the issue but using a (workaround) rather than resolving the root cause as I could not identify it.
First I have noticed that when sizing the hight of the screen I have 2 conditions:
below code will work with all iPhones but not iPads:
background1.size.height = self.frame.height
below code will work with all iPads but not iPhones:
background1.size.height = screenSize.height
So since the minimum hight of screen of iPads is 1024; I used the below code to first check if it is iPad use condition 2 and if iPhone use condition 1 as follow:
let screenSize: CGRect = UIScreen.main.bounds
if screenSize.height < CGFloat(1024) {
background1.size.height = self.frame.height ////for iphone
} else {
background1.size.height = screenSize.height ////for ipad
}
I am not sure what your case is.But it happens in iPhone 5+ devices due to launch screen size.Normally it behaves like iPhone 5 screen size even with iPhone 6,iPhone 6+.
Now the soultion.
1.You can use the default launch screen storyboard to avoid the problem.
2.You have to add every sizes for iPhone screen size (320*480,640*960,640*1136,768*1334,1242*2208).please add also iPhone 7,7+ sizes too.
3.You can use asset Catalogs for launch screen.
If thats the case for you please use above solution.It should work.

preferredContentSize not working in ios 7?

I am using modalPresentationStyle of type UIModalPresentationFormSheet to show my view.I want specific size of the view so using preferredContentSize which working in iOS 8 and showing exact how I wanted but same breaks for iOS 7 it's come as full sheet.View size changed.
Where as I wanted like below image
Any idea?
Please check below conditional code for iOS 8.x and iOS 7
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(#"8.0"))
{
modalController.preferredContentSize = CGSizeMake(frameSize.x, frameSize.y);
}
else
{
modalController.view.superview.frame = CGRectMake((screenWidth - frameSize.x)/2, (screenHeight - frameSize.y)/2, frameSize.x, frameSize.y);
}
Hope this will help you.

xcode 6 is iphone 5 no longer 568 points in height?

So I'm trying to update my game to fit the iPhone 6 properly and i see now that when i run my game on the iPhone 5 simulator, everything is fitting as if it were an iPhone 4. I use if statements to determine the height of the device:
if ((int)[[UIScreen mainScreen] bounds].size.height == 568)
{
mylabel4.fontSize = 35;
mylabel4.position = CGPointMake(CGRectGetMidX(self.frame) -145, CGRectGetMidY(self.frame) -130);
} else {
mylabel4.fontSize = 35;
mylabel4.position = CGPointMake(CGRectGetMidX(self.frame) -110, CGRectGetMidY(self.frame) - 130);
}
And like i said when i run the iPhone 5 simulator, it runs the code in the 'else' bracket. Its like the iPhone 5 is no longer 568 points in height. This was working fine until i download Xcode 6? What's going on here?
The UIScreen bounds behavior has changed in iOS8. Previously it would always give you width and height of the screen in portrait (so 320 x 568 on the iPhone 5), but in iOS8 it will give you width and height with respect to whatever orientation you're in, i.e. in landscape you would get 568 x 320.
If you want to get the bounds in portrait (like before), use:
[UIScreen mainScreen].fixedCoordinateSpace.bounds.size
Just add launch images for the iPhone and the simulator will display the proper points. Weird bug.

How to adjust UITableview margins from left and right programmatically?

i have a tableview(no table view cell). My Application is running fine in iOS 6 but when i am running it in iOS7 Tableview margin is conflicting.When i am setting up frame via Code its margin is only adjusting from left and bottom. i am using following code
if([[[UIDevice currentDevice]systemVersion]floatValue]>=7){
CGRect newSize = CGRectMake(0,0,730,925);
newSize.origin.y = 0;
newSize.size.width = 728.0;
newSize.size.height = 925.0;
self.myTable.frame = newSize;
}
Please suggest me something how can i resolve it
?
Here are images for ios 6 & ios 7 (Its a group table view ) i havent changed any margin for ios 7 its same as in ios6 ,and if i am doing any changes in ios 7 regarding margin its affecting in ios 6 layout too..
Add autoresize property
//ensure autosizing enabled
self.view.autoresizesSubviews = YES;
myTable = [[myTable alloc]initWithFrame:self.view.bounds];
[myTable setAutoresizingMask:UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight];
[self.view addSubview:myTable];

Resize TextView for 4" display? [duplicate]

This question already has answers here:
How to develop or migrate apps for iPhone 5 screen resolution?
(30 answers)
Closed 8 years ago.
How do I resize a text view so that it expands when displayed in the new 4" screens that it isn't shorter? I'm using AutoLayout. Also, I calculated that since the iOS keyboard takes up 216 points on both devices, and since the Navigation bar takes up 44 points on both devices, that the remaining view would be 200 points on a 320x460 screen. But how do I set this relative to the iPhone 5 screen? Any help would be appreciated. I've provided a screenshot to illustrate what I mean to better understand my issue.
Normal Screen (Works great!):
iPhone 5 Screen (Not so great!):
Try do like this:
self.view.autoresizesSubviews = YES;
self.textView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
Just ended up disabling autolayout for that specific view controller, and set my own CGRect.
CGRect largeScreen = CGRectMake(0, 1, 640, 290);
CGRect screenBounds = [[UIScreen mainScreen]bounds];
if (screenBounds.size.height==568)
{
[self.htmlText setTranslatesAutoresizingMaskIntoConstraints:YES];
htmlText.frame = largeScreen;
}
It is quite simple calculate height of textfield like this
CGFloat TextFieldHeight = self.view.frame.size.height - keyboardHeight- statusbarheight - navigationBarHeight;
Then assign this height to your textfield.
CGRect TextFieldNewFrame = textField.frame;
TextFieldNewFrame.size,height = TextFieldHeight;
textField.frame = TextFieldNewFrame;

Resources