iOS 6 View gets small after opening the app on iOS 7 - ios

I have view in my xib file whose height is 44 which contains buttons (like a toolbar).
It's working fine in iOS 7 now but when i open it in iOS 6 , the height of view gets small (24.0f) and so are the buttons in it.
Another thing is that, if i build the app with xcode 5 then the older versions of xcode will not be able to open xib files.
How to fix this issue? Help would be highly appreciated.

This is works for me
- (void)viewDidAppear:(BOOL)animated {
self.view.frame = CGRectMake(0, 0, 320, 00);
NSLog(#"%f", self.view.frame.origin.x);
NSLog(#"%f", self.view.frame.origin.y);
NSLog(#"%f", self.view.frame.size.width);
NSLog(#"%f", self.view.frame.size.height);
[super viewWillAppear:animated];
}

To answer of the second part of your question, the head of your xib file is different with XCode 5. But, with XCode 5 you can keep the old version of your xib using XCode 4.6 and iOS 6.
Go to your xib file and modify :
and use XCode 4.6 and iOS 6 :
With that, you can correct your bug with the 20px less in iOS 6.
You need to keep your xib file in iOS 6 and add a Content View below the view with a delta of 20px in Y and add your UI elements in this content view. like this :

Related

Simulator IPad pro (works) vs iPhone 6 plus

I have my mobile app in Objective C.
I have a scroll view page. In Simulator iPad Pro it works.
In Simulator iPhone 6 Plus, the scroll view starts at lower part of
page and I cannot get it back up to top. In fact all of
the iPhone ( 5,6,7) look like the iPhone 6 plus.ie the top of
the page shows "Grade" and "County". I cannot scroll up to see
"First Name". The only thing I am changing is the device.
Suggestions?
below is iPhone 6 Plus
SOLVED- During trying all several options, I
forgot I had:
-(void)viewDidLayoutSubviews{
[super viewDidLayoutSubviews];
// REMOVE the LINES BELOW
[self.scroller layoutIfNeeded];
self.scroller.contentSize = self.contentView.bounds.size;
self.contentView.center = self.view.superview.center;
}
After removing the 3 lines above, it worked correctly in iPhone 5, 6, 7.
The IPad worked WITH or WITHOUT those 3 lines.
I spent a lot of time on this. I hope this helps others.
are you using Constraints to setup your views? if so then try checking scrollview's top constraint whether its linked to Top Layout Guide's bottom ?

iOS simulator window height difference between 7.1 and 8.3

I didn't find any solution for my problem anywhere in Stack Overflow or other sites. So here is the problem:
I am developing an iOS Universal app, portrait orientation only. When I run it on iOS 8.3 simulator window and all other views layout seems to be normal.
But when I run the same app on iOS 7.1 simulator, which I downloaded from developer's site for Xcode 6, the window height seems to be approximately 100 px smaller.
I checked the couple of view frames for both simulators.
7.1 simulator was returning width = 320, height = 480
8.3 simulator returned width = 320, height = 568
I am using storyboard and constraints.
I am pretty sure that a lot of people had this problem, so I am hoping to hear some useful advices from you.
Check out the screenshots below:
Added Answer as per Brian Tompsett - 汤莱恩's Suggestion.
Solution is already done on comments.
iOS 7.x does not support LaunchScreen.xib
So, Manually add the LaunchScreens in the assets folder and you will get desired output.
Go to Project settings --> Target --> App Icons and Launch Images
Launch Image Source was empty so, open it and chose to Migrate from Images.
So now window height is back to 568 on iOS 7.1 simulator

iOS - UISearchBar width changes in iOS8

I have been using UISearchbar in my project with no problem at all in iOS7 now when i build my project using Xcode 6.0.1 and run on iOS8 the width of UISearchBar automatically changes for example
If my app is in landscape mode (iPad) and the search bar was in center and had 200 points then this width changes to full 1024 automatically.
I am not using auto layout, when i enable auto layout the issue is solved but whatever i do to change the frame in code nothing happens.
I don't want to enable autoLayout, how can i solve this problem?
I solved this problem by using following code
-(void)viewWillLayoutSubviews
{
searchbar.frame = CGRectMake(365, 0, 274, 44);
}
Hope this help someone

Size classes with xib files not working

Currently, I'm working on universal app (iPhone / iPad) supported on iOS 7 & iOS 8.
Here is my problem regarding size classes :
My navigation bar is defined into a XiB file (NavBarView.xib)
Inside this file, I have a UIButton that I want to display only on iPhone mode, and a UISearchBar only for iPad mode.
To handle that whitout any line code, I used the new feature "Use size classes" available for views since iOS 8. I defined "size classes" for these two elements inside my XiB file.
UISearch for Ipad : Installed for all layouts except Compact Width / Any Height (wC hAny)
UIButton fo Iphone : Not installed for all layouts but with Compact Width / Any Height (wC hAny)
This mechanism works pretty fine on iOS 8 for iphone and ipad, but not on iOS 7. However, if I apply these size classes direclty into views contained into the storyboard, it works for iOS 7.
Could anyone explain me why my size classes are not working when they are defined into XiB files on iOS 7 ?
Best Regards and many thanks,
Lorenzo.
Barely anything to do with size classes is supported under iOS 7. Some good answers here: How can Xcode 6 adaptive UIs be backwards-compatible with iOS 7 and iOS 6?
Adding as an answer since saadnib's comment on the original question helped me a lot.
Size classes on XIB files not being backwards compatible is a bug that has been fixed on xCode 6.1.1. Strangely it's not on the patch notes but I can confirm I'm using a single xib to provide 2 different layouts for a cell on iPad and iPhone. This only started working once I updated from 6.0.1 to 6.1.1.
Limitations on backwards compatibility for classes on storyboards still apply, but they can be worked around.
Figured another option. Size classes will not work, if you add xibs view as subview to UIApplication.shared.keyWindow.
View must be in UIViewController view hierarchy to support size classes.
Thanks to #IvanKvyatkovskiy

Same xib for iPhone4 and iPhone5 possible?

Is there any way I can design my classes for both iPhone4 and iPhone5 using the same xib?
Yes, you can use the same XIB to design for iPhone 4 and iPhone 5 by using Auto-Layout.
Build an app using iOS 6 as the Base SDK and use the Auto Layout feature to make screens that can scale for all type of screens. You'll need Xcode 4.5 to do this.
Get started with Auto Layout here:
http://www.raywenderlich.com/20881/beginning-auto-layout-part-1-of-2
http://www.raywenderlich.com/20897/beginning-auto-layout-part-2-of-2
Well short answer to you question is YES;
Long is :- If you user XCode 4.5 and build app that is universal the NIB files and Classes would work perfectly for Iphone 4 and Iphone 5; Understand for you it important to know the version of SDK of these mobiles not the mobile version them self.
Another thing is that iphone 5 size is little bigger then iphone 4 so you need to design accordingly.. please read my answer at Iphone 5 screen resolution issue for better understanding.
Also look at the How to develop or migrate apps for iPhone 5 screen resolution? answer for more clarification on universal app desing.
Add a image named Default-568h#2x.png. That will identify your app as one that supports iPhone 5 metrics. And also you need to do auto sizing of your views properly.
yes it is possible,
just remove the side angle and make object free by enabling inner arrow.
so it will automatically resize according to screen.
but remember one thing that this will only work when you provide all default or any other splash screen.
If you want to make some small changes(e.g images position and sizes, scroll view content insets..), you can use codes to differentiate between iPhone 5 and iPhone 4/4s, and implement your codes inside the if/else statement.
Use this:
https://stackoverflow.com/a/12447113/1371949
to detect the iPhone type.
You can use auto layout feature provided by apple. Please refer to apple document for this:-
https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/AutolayoutPG/Introduction/Introduction.html
Please define below line and check condition based on device.
#define IS_IPHONE_5 ( fabs( ( double )[ [ UIScreen mainScreen ] bounds ].size.height - ( double )568 ) < DBL_EPSILON )
if (IS_IPHONE_5) {
btnBookmark.frame=CGRectMake(0, 460, 100, 70);
btnBookmark.frame=CGRectMake(150, 460, 100, 70);
}else{
btnBookmark.frame=CGRectMake(0, 360, 100, 70);
btnBookmark.frame=CGRectMake(150, 360, 100, 70);
}
Use AutoAutoresizing so that u can make app compatible with both iOS 5 and iOS 6. This is easy if your layout is having minimum dependancies. And this is possible for fixing issues with components like UIToolBar. Buttons in iPhone 5.

Resources