1

This is for ios 7 looks perfectThis for is ios 6I spend a whole day to try that my make will be compatible for both ios7 and ios6,but tired.My app is running perfectly when I run in ios 7 and set the base sdk as ios7 and later. Also I put deployment target as 7.0.

Now when I set base sdk as ios6 and set deployment target as 6.1 then my app is still run but the problem is its GUI is distorted. Tried in simulator 6.1 and also getting this problem.

Navigation bar hides and all the images label textfield tableview are also set to bottom as they were as in fix position in ios7. I don't want to put 4 xib I already put 2 xib one for 3.5 inch display and for 4 inch display.

san
  • 3,350
  • 1
  • 28
  • 40
JohnWick
  • 241
  • 2
  • 13
  • why dont you use the autolayout it will solve your most of issue, also you need to check for which iOS is running so that you can adjust your view, look for a guide to upgrade – Retro Jan 09 '14 at 05:42
  • @Retro but if i use auto layout.and set navigation bar of 3.5 inch it will affect also to 4 inch display so how can i? – JohnWick Jan 09 '14 at 05:47
  • Use autolayout go through http://www.raywenderlich.com/50317/beginning-auto-layout-tutorial-in-ios-7-part-1 You dont need 2 or 4 xib you can do it using single xib. – Rahul Mane Jan 09 '14 at 05:49
  • PIN your any UIView to Top or Bottom it will automatically adjust view as per 3.5 or 4 inch device. – Rahul Mane Jan 09 '14 at 05:51
  • @RahulV.Mane i already make 2 xib and it is become hard coding is there any way? – JohnWick Jan 09 '14 at 05:51
  • @RahulV.Mane i didn't get PIN UIview means ?can you please provide me any reference? – JohnWick Jan 09 '14 at 05:54
  • No problem you can still use one xib. i have posted raywenderlich tutorial link, can you post your code in github or anywhere else so that i can demonstrate properly. Post only 1 screen if possible. – Rahul Mane Jan 09 '14 at 05:56
  • read the doc - https://developer.apple.com/library/ios/documentation/userexperience/conceptual/AutolayoutPG/Introduction/Introduction.html#//apple_ref/doc/uid/TP40010853-CH13-SW1 – Rahul Mane Jan 09 '14 at 06:00
  • @RahulV.Mane Where i have to post just give me link and i'll put my file of one screen there actualy i never used autolayout and constraints so i l'il afraid or give ur gmail so i can. – JohnWick Jan 09 '14 at 06:05
  • put it in dropbox.com n share public url. – Rahul Mane Jan 09 '14 at 06:13
  • @RahulV.Mane https://www.dropbox.com/s/zt0aerm9odz1qsm/Archive.zip – JohnWick Jan 09 '14 at 06:23
  • @RahulV.Mane did you check that brother.... – JohnWick Jan 09 '14 at 06:42
  • I have created one sample project https://www.dropbox.com/s/wwf8f9vsz2ptlac/AutolayoutDemo.zip Please it and reply if it works. Please read "ReadMe" file. Its most important – Rahul Mane Jan 09 '14 at 07:03
  • @RahulV.Mane but it is not running perfectly in when i run it into iphone simulator 6.1.can u please ellaborate the code which i put in dropbox by using autolayout. – JohnWick Jan 09 '14 at 07:12
  • R u asking about button overlapping on each other?? for now reduce the width of buttons. bcoz its perfectly working at my end. add screenshot where u find error. – Rahul Mane Jan 09 '14 at 07:18
  • @RahulV.Mane i post images please see – JohnWick Jan 09 '14 at 07:36
  • Ok i got it. Select View in Interface builder set Stutus bar = None. Its the same issue mention here http://stackoverflow.com/questions/18980925/status-bar-and-navigation-bar-issue-in-ios7 – Rahul Mane Jan 09 '14 at 08:35
  • @RahulV.Mane still not working brother – JohnWick Jan 09 '14 at 09:08
  • you can also just check which iOS you are running in the device and adjust the graphics accordingly – Totumus Maximus Jan 09 '14 at 11:46
  • @shoul i make 4 xib for each you controller – JohnWick Jan 09 '14 at 12:40
  • @TotumusMaximus should i have to make 4 xib? – JohnWick Jan 09 '14 at 12:41
  • @RahulShrimali You should make a xib for iOS6 and iOS7. and initialise the right when with a if-statement like this: "#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)". Where 'v' is the iOS version. – Totumus Maximus Jan 09 '14 at 12:43
  • @TotumusMaximus do u have full code for this???? – JohnWick Jan 09 '14 at 12:59
  • @RahulShrimali It's really easy let me put it into an answer for a better format ^^. Give me a moment tho. – Totumus Maximus Jan 09 '14 at 13:14

3 Answers3

1

For me if I have to make changes that are based on different iOS version I use the following class to define functions that can detect which version I'm using. It also only needs a header (.h) file and no implementation (.m) file.

I call this class VersionMacros.

VersionMacros.h :

/*
 *  System Versioning Preprocessor Macros
 *  Incluse this header if you want to adjust something based on a system version
 */

#define SYSTEM_VERSION_EQUAL_TO(v)                  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v)              ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v)  ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v)                 ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v)     ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)

//Use these functions to detect versions. Also import this header file into the file u want to use these funcs.

Then when you want to use a different xib for both versions you can just call this.

      if(SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO("7.0"))
      {
          //The version of the device is iOS7.0 or higher.

          //call controller with ios7 xib here
      }
      else
      {
          //The version of the device is lower then iOS7.0.

          //call controller with ios6 xib here
      }

Instead of making and calling different xibs you can also just adjust the frames of the elements that need adjusting. (this is what I prefer) This would look something like this.

float versionMarginY = 0.0;

if(SYSTEM_VERSION_EQUAL_TO("7.0"))
{
    //if system version is exactly 7.0
    versionMarginY = 64.0;
}
else if(SYSTEM_VERSION_EQUAL_TO("6.0"))
{
    //if system version is exactly 6.0
    versionMarginY = 44.0;
}
else
{
    //for all other versions we do this
}

//Then adjust a certain view that you can reach in this method
someView.frame = CGRectMake(0, 0 + versionMarginY, someWidthThatHasSomeKindOfValue, someHeightThatHasSomeKindOfValue);

Hope this helps!

Totumus Maximus
  • 7,543
  • 6
  • 45
  • 69
  • there is an error that what i have to put insted of V i have tried but it getting error. – JohnWick Jan 10 '14 at 06:23
  • what will be in SomeView? – JohnWick Jan 10 '14 at 06:57
  • Instead of v you should put the iOS version number as a string. Like "6.0" or "7.0" like in the example. SomeView will be elements from your xib that you can manage. Like some UIView you put on your xib and connected with your viewcontroller – Totumus Maximus Jan 10 '14 at 07:35
  • you mean i have to set iboutlet for each class and set uiview? – JohnWick Jan 10 '14 at 08:51
  • Yes, exactly. You can set the IBOutlet to get a handle on the view (or views) that needs adjustments. – Totumus Maximus Jan 10 '14 at 08:59
  • View1.frame = CGRectMake(0, 0 + versionMarginY, 320, 480) i put it in view did load but error occured that property frame is not found as an object of homeViewController. – JohnWick Jan 10 '14 at 09:10
  • a ViewController doesn't have a frame indeed. A UIViewController has a view-property. This view-property has a frame. – Totumus Maximus Jan 10 '14 at 09:18
0

I used this condition to fix graphical issues by code working with iOS 6 and 7

if(floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1){
        //make it look nice iOS7
}
-1

Add a flag in info.plist(view controller based...the lastone from plist) set it to NO