Supporting iOS 4.3 to iOS 6.0 - iphone

I already have the base code that supports ios 4.3 to ios 5. Now I would also like to support ios 6.0.
The present base code has modal views, hard coded CGRect's, and rotation is different for each view. So I would like to know whether we can support ios 4.3 to ios 6.0 with the same base code, by just tweaking some changes, or do we need to create a complete new target?
Like we cannot use auto layout of ios 6.0 if I want to support previous versions as it will lead to a crash.

Yes, we can do this by setting up the Deployment Target to iOS 4.3. But then, why do you need to support iOS < 5.0 as around 85-90% of devices are on iOS 5.0+. See this
Also, when you set up support for iOS 4.3 or even iOS 5.1.1, you would have to handle multiple things. For example, the method for Orientation,
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
isn't called for iOS 6. It is replaced by the methods,
- (NSUInteger)supportedInterfaceOrientations
- (BOOL)shouldAutorotate
You would need all the iOS versions on devices and then test each and every aspect of your app.

Using Xcode 4.5 it is perfectly valid to use one code base for building iOS 4.3 - 6.0 apps, but as always the key is testing on real iDevices with the given operating system versions.

Yes it is perfectly fine and can be done to support ios 4.3 to ios 6.0 using the xcode 4.5.
And for the orientations in ios 6 have to do some work around like have to put some code differently as posted in #Mayur J's answer.
Or all you can do is just add categories for the required controller's like UINavigationController, UIPopoverViewController, UIImagePickerViewController, etc to return the supported orientation in ios 6.0 like below
.h file
#import <UIKit/UIKit.h>
#interface UIPopoverController (UIPopoverController_Orientation)
-(NSUInteger) supportedInterfaceOrientations;
#end
.m file
#import "UIPopoverController+UIPopoverController_Orientation.h"
#implementation UIPopoverController (UIPopoverController_Orientation)
-(NSUInteger) supportedInterfaceOrientations {
return UIInterfaceOrientationMaskLandscape;
}
#end
Here I use UIInterfaceOrientationMaskLandscape as I only supports landscape orientations ie restrict my app to only landscape mode.
Hope this will help you.
Happy Coding :)

Related

Views are portrait in older versions

I have a problem here and am not able to come up with answer why my app is behaving so.
I made application using XCode 4.5+ and iOS6 and have set my application to work in landscape mode it was working and running fine till I tried to run it in previous version like iOS 5.1 simulator or below all views are in portrait mode :(
You can try defining this method in your controllers:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return ( interfaceOrientation == UIInterfaceOrientationPortrait)ç
}
This plays the same role as shouldAutorotate for iOS6.
as suggested by tkanzakic - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOr‌​ientation solved my problem with lower versions thanks a lot :)

iPhone 5.0 and 5.1 Simulators Not Calling IBActions?

I have an app with a target of iOS 5.0. Unfortunately, I no longer have any test devices with iOS 5.
I'd like to be able to use the iOS 5.0 and 5.1 simulators to do basic debugging, but for some reason, my IBActions aren't being called on these simulators.
Further info:
Xcode version is 4.5.2
All simulators are up-to-date (no pending updates/downloads available)
We do have customers who use iOS 5 and 5.1, and they don't have any issues clicking the buttons (or at least, we haven't received any reports about such from them ; )
On the iPhone 6.0 simulator, everything works as expected (pretty sure all IBActions are connected correctly)
Are these simulators just terribly buggy (is this a known issue)? Have others ran into this issue and know a fix?
It turns out that a UITapGesture on self.view was capturing the touches and NOT forwarding to the subviews... for some reason, this behavior appears to be different in iOS 6 and iOS 5 simulators... user beware...
Most Probably issue i seen that..
might be you not define your IBAction method in .h file.
might be you connect two IBAction on one UIButton TouchUpInside.
you also try uninstall app from simulatore clear xcode than might be solve your issue.
reset you simulator contain.
Check is any update of Xcode then you try to run your app then you got solution.
I am working on same configuration and i have no issue like yours..
Use UIGestureRecognizerDelegate to avoid effect of gestureRecognizer on a selectedView:
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)recognizer shouldReceiveTouch:(UITouch *)touch {
UIView *selectedView = self.view;
CGPoint point = [touch locationInView:self.view.superview];
if (CGRectContainsPoint(selectedView.frame, point)) {
return NO;
}
else {
return YES;
}
}

iOS 6 orientation changes have me totally confused

This is a universal app and I have the supported interface orientations for both iPhone and iPad targets set only to Landscape Left and Right. My root view controllers do not use a NavigationController and the xibs are landscape oriented views. The app is designed to only use the landscape orientations.
In application:didFinishLaunchingWithOptions I have...
if (([JLHelper isIPhone]) | ([JLHelper iPadPortraitRestricted])) {
application.statusBarOrientation = UIInterfaceOrientationLandscapeRight;
}
In iOS 5 everything worked fine but In iOS 6 the view does not display in a landscape orientation on startup.
I understand that shouldAutorotateToInterfaceOrientation has been deprecated in iOS 6, but I do not understand why this affects the initial presentation. It appears to me that the root view is being rotated.
I have read many discussions on how to force landscape orientation in iOS 6 and am now totally confused. There must be a simple way to implement an app that only uses landscape orientation.
You can specify the supported orientations in the info.plist for iOS 6. Additionally you can implement the shouldAutorotate method and the supportedInterfaceOrientations methods (new as of iOS 6) to conditionally restrict orientations for iOS 6.
Note that if you want to continue to support iOS 5 you also have to have the shouldAutorotateToInterfaceOrientation... method in place. iOS 5 uses the old method, iOS 6 the new one, they can coexist.

How to enable "AutoLayout" of iOS 6 programmatically?

How can I enable "AutoLayout" programmatically. Actually I have to create an app which should run on iOS6 and iOS5 but we can enable "AutoLayout" in the XIB in iOS 6 only and it will not work on the iOS 5 so I am checking the iOS version and using if else condition for the appropriate task according to the iOS. So if app would be running on iOS 6, I will enable the AutoLayout otherwise I will write the code for AutoResizing. Please let me know if I am unclear at any point.
If you want autolayout on iOS6 devices but not iOS5 (unuspported) but still want to use nib's, you have to keep separate nibs. One for iOS5 and one for iOS6.
When loading your nib, check if autolayout is supported by checking if the NSLayoutConstraint class exists:
if (NSClassFromString(#"NSLayoutConstraint"))
//Load iOS6 nib with autlayout.
else
//Load iOS5 nib sans autolayout.

Make iPhone app compatible with iOS 3

I have developing an iPhone application using xcode 4 which is compatible with iOS 4.3 and runs on iPhone 4 device smoothly. My question is how to check whether my application is compatible with iOS 3 or not.I do not have any iOS 3 device to run the app so the only solution is to check the compatibility for iOS 3 is simulator but I have not found any option to run the app on iOS 3 simulator.
Any suggestion how to install SDK for iOS 3.
Thanks
The only way to be sure of compatibility is to borrow or buy a device running iOS 3 for testing. The Simulator, even an old one, is not accurate enough to ensure compatibility.
If you can't find a device still running 3.x anywhere, even just to borrow for an hour, why bother with compatibility with such a rarity?
Here's my checklist for iOS 3:
make sure that your app runs fine on slow CPU and less memory.
support armv6. add armv6 to architectures, remove armv7 from required device capability, and disable thumb on armv6 if your compiler has code generation bug.
don't use ARC, whick is not (officially) supported on iOS 3.
check for existence of newer method (with respondsToSelector:) or class, instead of checking the OS version in most cases.
don't use gesture recognizers which did exist on iOS 3 but were private API, and lack important methods. you need to handle touch events manually.
if you use blocks, you need to link the system library dynamically, and it requires iOS 3.1 (I've heard that iOS 3.0 doesn't support dynamic link.)
Here is an example application:didFinishLaunchingWithOptions: method.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
self.viewController = [[[ViewController alloc] initWithNibName:#"ViewController" bundle:nil] autorelease];
if ([self.window respondsToSelector:#selector(setRootViewController:)]) {
self.window.rootViewController = self.viewController;
} else {
[self.window addSubview:self.viewController.view];
}
[self.window makeKeyAndVisible];
return YES;
}
Tap the project, tap your target, tap Summary, set your Deployment Target to 3.x. Then the Scheme pulldown in the top of XCode will show you options to run it in the 3.x simulators.
On the iOS developer center there's a download link to Xcode 3. That one might include iOS 3.