Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 8    Views: 28

NCbuzz
Code is Art
Profile
Posts: 575
Reg: Sep 11, 2013
Lillington, NC
11,100
10/02/14 06:47 PM (9 years ago)

How to reference value of Switch, Segment etc. (USC)

Sure I am missing something obvious. I have an Ultimate Screen Creator screen that has: Switches and a Segment (and would also like to use a Slider) + Screen Save and Load restores the previous state when loaded. However what I need is an example of how to reference the selected value. (For example the Switch is ON, or the selected Segment is 2. Chris1- Is there a small USC doc or sample code that covers some of these basics of tying USC elements to code. Maybe I am missing a readme that was posted somewhere...
 
PaddyO
Lost but trying
Profile
Posts: 189
Reg: Sep 11, 2013
Geelong
5,190
like
10/06/14 10:32 PM (9 years ago)
NCBuzz I may be missing what you're asking, but something like this? if(segment.selectedSegmentIndex == 1){ // Second segment button is clicked - first segment is segment '0', 3rd segment is '2' etc // stuff happens }; Cheers Paddy
 
NCbuzz
Code is Art
Profile
Posts: 575
Reg: Sep 11, 2013
Lillington, NC
11,100
like
10/07/14 06:28 PM (9 years ago)
Thanks for the tip Paddy. That makes sense for adding code based upon what segment was clicked... However in the Ultimate Screen Creator world, I have no idea where to place the code. Don't see where in CR_ultimateScreen Creator.m where this could be placed. Once I figure that out, I assume will then need to add logic based upon what USC screen is active so can handle segments on different screens. That's why I thought Chris must have had a readme that I missed... but I have not seen a singly reply from Chris on any of my Ultimate Screen Creator questions.
 
PaddyO
Lost but trying
Profile
Posts: 189
Reg: Sep 11, 2013
Geelong
5,190
like
10/07/14 07:14 PM (9 years ago)
Can you extend that logic (this will just show that I have no USC experience at all :)) so that when a switch is selected and it goes to a screen, you just add your 'stuff happens' code to the screen in onViewDidLoad or similar? Assuming that each switch is directly linked to one screen and one screen only? Or are you floating your UISWitch above multiple screens? The other thought is that you could set it up to create a .txt file in memory that holds the value of the UISwitch position between saving and reloading; that way the switch position will be 'recorded' and the plugin will grab it out and set it to its 'on' value as the default when it reloads. I see this (create a cached file) happening in most of the map plugins where it looks for a cached file on refresh, and the cache is some value that has been established during the previous session. May be worth a poke around in some of those, search for ".txt" in a few plugins and see what turns up that you could modify.
 
PaddyO
Lost but trying
Profile
Posts: 189
Reg: Sep 11, 2013
Geelong
5,190
like
10/07/14 07:23 PM (9 years ago)
Just found it in BT_screen_map: Look for this - -(void)loadData{ [BT_debugger showIt:self theMessage:@"loadData"]; self.didInitialPinDrop = 0; /* Screen Data scenarios -------------------------------- a) No dataURL is provided in the screen data - use the info configured in the app's configuration file b) A dataURL is provided, download now if we don't have a cache, else, download on refresh. */ //this creates a txt file in memory that includes the screen id of the BT map screen item. It becomes the cached file. self.saveAsFileName = [NSString stringWithFormat:@"screenData_%@.txt", [self.screenData itemId]];
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
10/07/14 09:17 PM (9 years ago)
Creative work there, Paddy! :-) -- Niraj
 
NCbuzz
Code is Art
Profile
Posts: 575
Reg: Sep 11, 2013
Lillington, NC
11,100
like
10/08/14 05:27 PM (9 years ago)
Interesting approach Paddy. The reason I really need Chris to chime in is because USC works very different. Out of the box it has the ability to load and save settings for all of the elements on that screen. Very cool, so a switch or segment is in the same state as when the user last left the screen. (This code is all exposed in CR_ultimateScreenCreator.m) Buttons can be used to send to screens. So I suppose instead of using a Segment, I could have several buttons to achieve those different actions. But I would like to set variables and/or do actions on the same screen based upon selecting different segments, but have no clue on where to place code following a tap on one of these elements. Like you suggested: if(segmentName.selectedSegmentIndex == 1){ // Second segment button is clicked - first segment is segment '0', 3rd segment is '2' etc // stuff happens }; I have started several threads with different questions on USC, however the experience is not out there, and Chris1 has not replied to any. I guess it is time to throw in the towel on USC- as there is no support at all. Had so much potential...
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
10/09/14 07:19 AM (9 years ago)
Mustang, I just sent an email to Chris to take a look at your recent posts. Let's hope he is able to pop up from his daily life soon. -- Niraj
 
NCbuzz
Code is Art
Profile
Posts: 575
Reg: Sep 11, 2013
Lillington, NC
11,100
like
10/09/14 03:05 PM (9 years ago)
Thanks Niraj.
 

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.