tags:

views:

205

answers:

2

My app requires one set of tabs on the initial view, the last tab item is reserved for an in-app purchase once the user selects. However, once the user makes the in-app purchase I would like a new set of tabs to appear. I would like for the user to be able to switch back and forward between the free part of the app and the in-app purchase part of the app with different tab bars. For example:

"TabBar1" to have "TabItem 1", "TabItem 2", "TabItem 3", and "TabItem 4" for my Free App, when user selects "TabItem 4" ...a welcome or in-app purchase screen will appear. If user makes the in-app purchase, "TabBar2" appears with "TabItem 1", "TabItem 5", "TabItem 6", and "TabItem4". "TabItem1" will bring you back to Free part of app and "TabBar1" when selected again. Hope I didnt confuse...How do you accomplish this? Thanks for the help.

I forgot to add that this Tabbar is to be combined with a Navigation controller as well.

A: 

While this might be possible, I would highly suggest against it from a User Experience perspective. Swapping a core piece of the navigational UI out from under the users nose is bound to confuse some users and it not really needed in this situation.

There are plenty of other ways to give feedback to the user, and plenty of ways to handle in-app purchases and I highly recommend doing some mockups of methods that could not potentially confuse the user.

coneybeare
A: 

you can change the views of root tabbarcontroller anytime you want, also you can change tabbaritems title & icons. Here's an example:

MyAppDelegate *appController = (MyAppDelegate *)[[UIApplication sharedApplication] delegate];
    // Setting 1st tab + view + icon
    ViewController1 *viewController1 = [[ViewController1 alloc] initWithNibName:@"ViewController1" bundle:nil];
favoritesController.title = @"Tab1 Title";
UINavigationController *navigationTab1Controller = [[[UINavigationController alloc] initWithRootViewController: viewController1] autorelease];
UITabBarItem *anItem = [[[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemFavorites tag:0] autorelease];
navigationTab1Controller.tabBarItem = anItem;

    // Setting 2st tab + view + icon
ViewController2 *viewController2 = [[ViewController2 alloc] initWithNibName:@"ViewController2" bundle:nil];
searchController.title = @"Tab2 Title";
UINavigationController *navigationTab2Controller = [[[UINavigationController alloc] initWithRootViewController:searchController] autorelease];
UITabBarItem *anItem1 = [[[UITabBarItem alloc] initWithTabBarSystemItem:UITabBarSystemItemSearch tag:1] autorelease];
navigationTab2Controller.tabBarItem = anItem1;

    // Now setting the array of tab views, each one attached to its navigation controller
NSArray *array = [[NSArray alloc] initWithObjects:self.navigationController, navigationTab1Controller, navigationTab2Controller, nil];
[appController.tabBarController setViewControllers:array animated:NO];
appController.tabBarController.selectedViewController = self.navigationController;
UITabBarItem *anItem2 = [[[UITabBarItem alloc] initWithTitle:@"Tab3 Title" image:[appController thumbnailImage:@"image"] tag:2] autorelease];
self.navigationController.tabBarItem = anItem2;

I'm changing the set of views and tabs, depending of the state of my application. Hopefully it helps

EDIT: function thumbnailImage is a function I wrote for caching images and avoid memory leaks, you can use imageNamed instead or other technique that retrieves an image from a bundle.

Nava Carmon
Thanks Nava Carmon for the instant reply. I am now having trouble implementing this code. Can you give me a briefing on setting this up. This piece of code will be the backbone of my app and all though Im very technical, I am new to coding so I may need you to hold my hand to implement this code into my project. Any help is welcomed
SympleMyne
Can you elaborate what the problem is? Please provide more details. I'll gladly will help
Nava Carmon