Error when testing iOS 5 app in Deployment Target 4.2 - ios5

i have made an application with storyboard and the new iOS 5 feature like this:
[[UINavigationBar appearance] setBackgroundImage:navigationBarImage forBarMetrics:UIBarMetricsDefault];
if i try to test the app Deployment Target to 4.2 for the user that still have that firmware, i receive an error in the line i write above, so my question is how i can test my app on 4.2 device?

For something which only works on iOS 5, you can do the following.
You can try to get the version by this way :
float version = [[[UIDevice currentDevice] systemVersion] floatValue];
And you try which version the user has before your code :
if (version >= 5.0) { your code }

Related

Compiling to a different iOS version

I have an application in the App Store, targeted for iOS 5, that runs correctly in iOS 6, and even iOS 7, but now, I wanted to add a new feature (just one new view with a controller).
The problem comes here: If I do compile the code with Xcode 5, it looks awkward, top status bar disappears, and even some views stop working.
I know this App needs a rewrite from Zero for iOS 7, but in the meantime, is there any way to make it work like it did before?
Can I somehow download a previous SDK, and in such case, will I be able to update the app to the App Store?
You need to copy the 6.1 SDK from an older version of Xcode into the Xcode.app you've got now, and then select the 6.1 SDK specifically in the build settings.
For the device this is /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.1.sdk, and for the simulator it is /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk. The paths are the same.
Just download Xcode 4.6 from the developer page and use it parallel with Xcode 5.
But you don't really need to rewrite anything...
Just make a subclass for UIViewController with a following code and use that instead the default.
- (void) viewDidLoad{
#if __IPHONE_7_0
if ([self respondsToSelector:#selector(setEdgesForExtendedLayout:)]) {
[self setEdgesForExtendedLayout:UIRectEdgeNone];
}
#endif
}
Also don't forget that all UINavigationController is translucent in 7 and up and not translucent below.

set self.navigationItem.rightBarButtonItem background image cause crash

I used the codes below to set the background image of self.navigationItem.rightBarButtonItem
[self.navigationItem.rightBarButtonItem
setBackgroundImage: [UIImage imageNamed:#"top_button.png"]
forState:UIControlStateNormal
barMetrics:UIBarMetricsDefault];
it will cause crash,
I used Xcode 4.3, deploy target 4.0, iPhone os 4.3.3
It worked well on simulator 5.1, but crashed on device
Welcome any comment
That method is only available on devices running iOS 5.0.
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIBarButtonItem_Class/Reference/Reference.html
the method u are trying to use is only available on iOS >= 5.0.
in Simulator you are using iOS 5.1.1 which is >= 5.0 so it works.
on your target devices os = 4.0/4.3.3 which does not have this support.
either you need to test on target device iOS >= 5.0 or you need to drop out the use of this method for iOS devices < iOS 5.0
Available in iOS 5.0 and later.

UIKeyboardTypeDecimalPad for currency field in 4.3 iphone sdk

I am not able to successfully use UIKeyboardTypeDecimalPad when i run on simulator 4.3 and it successfully works on simulator 5.0. I have currency to be filled in textfield.
How can i use UIKeyboardTypeDecimalPad for device running 4.3 ?
Edited
in simulator 4.3 it is giving following warning:
"Can't find keyplane that supports type 8 for keyboard iPhone-Portrait-DecimalPad; using Default"
I think it's a warning because i am using IOS 4.3 and it's printing that error in Logs and working perfectly.I am using following code
- (void)viewDidLoad
{
[super viewDidLoad];
myTextField.keyboardType=UIKeyboardTypeDecimalPad;
}
simulator autocorrection was called which crashed my app..
it is Lion 10.7.2 + Xcode 4.2 + Simulator running iOS 4.3 problem
Now solution to it is
We have to update Simulator 4.3 , by following this steps: 1) Go to Xcode->Preferences->Download 2) Update iOS 4.3 Simulator
And Reset Simulator ,and run it again... its done...

iPad with iOS 3.2 compatibility with iPhone iOS 3.0

Recently submitted iPhone and iPod Touch application to app store successfully, but later came to know that is not working on iPad 3.2 but works on iPad with high iOS like 4 in scaled version.
Reason: setOrientation property of Movie player.
Actual Query: In order to make it work on iPad 3.2 in MAC Desktop I used
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
player.view.frame = CGRectMake(0, 0, 768, 1024);
[self.view addSubview:player.view];
[player play];
}
else {
#ifdef __IPHONE_4_0
player.controlStyle = MPMovieControlStyleNone;
#else
[player setOrientation:UIDeviceOrientationPortrait animated:NO];
}
when i run the same code on my MAC BOOK with iOS 3.0 this code is throwing the error...not supported.
So
If i build the above code on MAC DESKTOP(with iOS 4) will that work
on iPhone device with iOS 3.0 ? ..in reference to Event Kit Frame
Work(which throws error in iOS 3.0..but required in iOS 4).
I need to go for separate iPad app instead of Universal?
Is there any difference in iPhone with iOS 3.2 and iPad with iOS 3.2 in terms of
properties used?
I don't think you should hardcode it like that at compile time. Instead you should test if a particular class or method/property on a class exists and then do the appropriate thing. Like using [NSObject respondstoSelector:] to test whether your object understands a particular method.
Okay, first of all it does not matter if you use the Mac desktop or the MacBook to compile. It looks like you may be confusing the "minimum iOS" value and the "base SDK".
Base SDK: Refers to the code library that the complier will use to check your code, but does not determine which OS's your app will actually run on. You can have a base SDK of 5.0 and your app may still work fine on a 3.0 system. The catch is that if you are using code that is compatable with your Base SDK and not older OS's, the compiler will not catch it.
Minimum OS: This value does determine which OS's your app will run on.
If you are using code for higher OS's but want to run on lower OS's you need to test in the code for which OS you are running on and then run the appropriate code for that platform.

UIModalPresentationFullScreen gives error in UniversalApplication

i am created Universal application, in that i used UIModalPresentationFull, for displaying MFMailComposerSheet in iPad, which helps me to show the full screen of a MailComposer view in landscape view of ipad. When i run the application in ipad simulator i works well. If i set it to iPhone simulator 3.0 or 3.1.3 it shows the error like "error: 'UIModalPresentationFullScreen' undeclared (first use in this function)" when i comment it and run in iPhone simulator it works what would be the solution for this error or, else is that any method replaces "UIModalPresentationFull" works in both ipad and iphone?
Thanks and regards
Venkat
UIModalPresentationFullScreen is only available in the 3.2 (and above) SDK so you can't compile it with a SDK lower than that.
However, you don't need to for a universal application - you compile it against the highest SDK you are going to run on and then you have to check at run-time if the methods / classes you are using are available. You set this in your build settings : Base SDK should be set to the highest SDK you are using (probably 3.2 for the iPad) and iPhone OS Deployment Target should be set to 3.0 - the lowest SDK on which your code can run.
You should be doing this each time you use a 3.2 only bit of code :
if ([controller respondsToSelector:#selector(setModalPresentationStyle:)])
[controller setModalPresentationStyle:UIModalPresentationFullScreen];
Then, even though you have compiled against the 3.2 SDK, when you run it on lower SDK devices, this method will not be run.
I test this on an iphone that still has 3.0 SDK on it. I don't know exactly how you would test in the simulator with a lower SDK sorry.
enter code here
Using conditional compilation block we can isolate the process for iPhone and iPad
" #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 30200 "
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
// The device is an iPad running iPhone 3.2 or later.
if ([picker respondsToSelector:#selector(setModalPresentationStyle:)])
{
//picker.modalPresentationStyle = UIModalPresentationFullScreen;
[picker setModalPresentationStyle:UIModalPresentationFullScreen];
}
}
" #endif "
Please remove the quotes and use that if and else part too...(i.e)conditional compilation block