Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 3    Views: 67

amysus
Lost but trying
Profile
Posts: 90
Reg: Oct 28, 2011
traveling the w...
3,650
06/08/16 12:31 PM (8 years ago)

How to Create 3 Paths - 3 Screens from 1 Tab?

Anyone know ... Is there a way to have a control menu (e.g., in the iOS settings menu, or within the app itself) that will change the screen linked to from a tab? That is, I have a default starter screen, and I also have two variations on that screen. I'd like to give the user the option of choosing which starter screen they see/use. This will not be something they'd want to change frequently (typically), so it can be buried a bit in the app or phone. And I don't want to make them have to choose each time they access the tab, that would be annoying. Or, perhaps on the very first screen (a home screen/settings screen) I give them this option ... but still, how would I change the screen that the tab goes to? Ideas? Thank you all. Amy
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
06/09/16 02:32 AM (8 years ago)
Among all the other stuff you'll eventually want to read, although not 'current', most of the same concepts and methods apply. http://www.buzztouch.com/docs/v1.5/ These are the documents for BTv1.5 and although we're at 3.0 (and eventually 4,5, etc...) there are some things that are done differently. "But not that much". One of the things you'll want to be aware of is the way BT sets up the Home Screen. If you're using a tabbed app, the 'home screen' will be Tab #1. If you're not using a tabbed app, the home screen will be whatever you assign it to be. However, again notice in the BT_config.txt file (your app json configuration) that the Home Screen will be the first screen in the json for 'BT_screens'. This is so the app will know which is the home screen out of potentially several hundred or more. So regardless of which screen 'you want' as a home screen, with respect to BT logic, it will only be Tab #1, or the assigned home screen. Now that we know we can't do it, let's figure out how to do it. If you don't mind playing test pilot, try this: 1) always keep a backup of your data. We're going to play within the code. 2) Select a BT_screen_menuButtons as your 'home screen'. 3) Download your project, and within xcode, open the BT_screen_menuButtons.m file 4) around line 125ish should be the 'viewWillAppear' method. Locate this line: [self performSelector:(@selector(loadData)) withObject:nil afterDelay:0.1]; replace it with this code: NSInteger defaultScreen = [[NSUserDefaults standardUserDefaults] integerForKey:@"defaultScreen"]; if (![defaultScreen == nil]) { BT_item *thisMenuItem = [self.menuItems objectAtIndex:defaultScreen]; [self performSelector:@selector(launchScreen:) withObject:thisMenuItem afterDelay:.2]; } else { [self performSelector:(@selector(loadData)) withObject:nil afterDelay:0.1]; } and in your "menuItemTap" method, after "BT_item *thisMenuItem = [self.menuItems objectAtIndex:i];" paste this code: NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; [prefs setInteger:i forKey:@"defaultScreen"]; and I *think* it might work. Of course, it might not work; I'm just doing this in my head without xcode started, so if it doesn't work, let me know. It certainly should work 'in theory', but I may have mistyped some of the methods etc... so in advance, mea culpa. But here's what we're trying to do: The app starts... the world waits breathlessly... Unknown to the User, in the 'viewWillAppear' code, the system pokes into NSUserDefaults to look for a "defaultScreen" value, and finding the value nil, will move along to the normal 'loadData' method. The user is presented with a 'beginning' home screen; the menu buttons, with button choices for which screen they prefer. They choose a button. In the 'menutap' method, we also record the users choice via an integer written to NSUserPrefs as the value for 'defaultScreen'. The 'next' time the user opens the screen, the value for 'defaultScreen' will not be nil, but instead contain the value of the previously saved "defaultScreen". It will grab the indexed menuItem and procede to launch the appropriate screen. All the world smiles. If it works. Cheers! -- Smug
 
amysus
Lost but trying
Profile
Posts: 90
Reg: Oct 28, 2011
traveling the w...
3,650
like
06/09/16 02:53 PM (8 years ago)
Brilliant! Thank you - happy to be test pilot. I will give this a spin. And, I am now recalling that (I think) I saw a plug in that allowed the user to change something similar ... I may take a peek at that too, if this does not work. Stay tuned, I'll let you know either way. Best, Amy
 
amysus
Lost but trying
Profile
Posts: 90
Reg: Oct 28, 2011
traveling the w...
3,650
like
06/09/16 04:26 PM (8 years ago)
Ok, I got one error, build failed. On the line as shown here, it says in red, Expected identifier. if (![defaultScreen == nil]) { Also, just thought of one more thing - we need to allow the user to change this setting when they want. The app I was thinking may work (but I can't really tell from the description) is Strobe's AppTransformer. I may try that too. If all fails, I can just make the user select an option each time, wouldn't be the worst (I think that as long as the user does not quit the app, tapping the tab will take him to the last page seen, not the first/home page in that tab section). But we are hoping to avoid this. Thank you for all of your support and info! Amy
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.