Reputation: 893
I have an UICollectionViewController
into TabBarViewController
that works for iOS 6.0
and later ios versions. I would like to know if there is any way to use a different ViewController
if a device has elder than iOS 6.0
version. For example, can i use a UITableView
for devices that use prior version than iOS 6.0
and UICollection
for devices that use iOS 6.0
and posterior versions?
I also tried PSTCollectionView
but it has some problems.
I added an image that shows my storyboard. My collection is in TabBarController and i want to change to TableView if a device uses prior to iOS 6.0 .
Upvotes: 2
Views: 131
Reputation: 9867
There is very simple solution to it
For Example In your tabBarControllers index 2 is for CollectionView and on 3 is for TableViewController
simply do all required settings icons names etc in storyboard
now in your ApplicationDidFinishLaunchingWith Options do this
As I assume your tabbarController is rootViewContrller do this
UITabbarController *tabbarController = (UITabBarController *)self.window.rootViewController;
NSMutableArray *arrayControllers = [NSMutableArray arrayWithArray:tabbarController.viewControllers];
if (OlderVersion) {//Check
[arrayControllers removeObjectAtIndex:2];
}else{
[arrayControllers removeObjectAtIndex:3];
}
[tabbarController setViewControllers:arrayControllers];
Upvotes: 4
Reputation: 3914
Yes, You can do that with checking following condition for your version.
NSString *currSysVer = [[UIDevice currentDevice] systemVersion];
float versionValue=[currSysVer floatvalue];
if(versionValue>=6)
{
// do some stuff you want to do here
}
Hope that helps you.
Upvotes: -1
Reputation: 25459
You need to add identifier to your view controller
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
if(versionValue>=7)
{
UIViewController *vc = [sb instantiateViewControllerWithIdentifier:@"viewControllerIOS7"];
}
else
{
UIViewController *vc = [sb instantiateViewControllerWithIdentifier:@"viewControllerIOS6"];
}
Hope this help.
Upvotes: 0
Reputation: 20410
Yes, you can do that.
Just get the version of the phone with this:
[[UIDevice currentDevice] systemVersion]
And then, load the right view controller depending on the value.
Upvotes: 0