Question

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 .enter image description here

Was it helpful?

Solution

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];

OTHER TIPS

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.

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.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top