Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 6    Views: 50

NCbuzz
Code is Art
Profile
Posts: 575
Reg: Sep 11, 2013
Lillington, NC
11,100
02/17/15 08:16 AM (9 years ago)

Using Ultimate Screen Creator Element values in code (iOS) - solved

I purchased the plugin last year, and has been awhile since I have used it. Layout of screens is super easy, but how to use the data. Is there a small how-to document or a thread I missed that already talks about using the values of screen elements in your code? (Text, Label, Image, etc.) 1) How would you assign the value of the USC Text element named 'username' to a nsstring variable in Xcode? - SOLVED (used getPrefString) 2) Same question for a USC image element to UIImage? - SOLVED (used getImageFromFile) For example the demo on YouTube shows using the Slider Element to change the value of a Label Element- how do you then use that value in your code? I was able to figure out today, and figured I would post for anyone else with the same question. Thanks
 
Bonzo
Apple Fan
Profile
Posts: 783
Reg: Jan 30, 2012
Basingstoke
13,530
like
02/18/15 08:56 AM (9 years ago)
NCBuzz I wanted to do something similar with this plugin. For example, have 2 text fields and then do a calculation between the 2 Value 1 x Value 2. Can you supply some same code to get me started here on how you use the 'getPrefString'? Would really appreciate it Thanks Steve
 
Fingers Crossed
Veteran developer
Profile
Posts: 234
Reg: Jan 16, 2012
Simcoe, ON
6,390
like
02/18/15 06:12 PM (9 years ago)
Well, I too am trying to achieve this. Ultimately I want to post a message to Facebook to include a value that USC created. Think ball game score. "Yay, team won 4 - 3" I'm using a stepper, and I have got as far as knowing the value changed. in CR_UltimateScreenCreator.m there is 'stepperDidChange' There are other methods for other controls. In there, I found this line.. UILabel *labelToChange = (UILabel*)[self.scrollView viewWithTag:(labelNumber+1000)]; This is where it changes the text for the stepper I selected. Here is where I somewhat cheated. After putting in a show alert to get the label ID, I hard coded the controls like this... NSString *labelId = [self getJsonPropertyValue:theElement.jsonVars nameOfProperty:@"elementStepperLabel" defaultValue:@""]; if ([labelId isEqualToString:@"LoK538ZpJpHo"]) { [self showAlert:@"Teams Score is " theMessage:labelToChange.text alertTag:0]; } The label id you can see in the USC visual setup. It would be super to see something like a post to Facebook with &LoK538ZpJpHo Above this code is the look where it looks like it cycles through all the controls to find the one it wants. Next up I want to try and save the values to device upon change. Pressing a "Save" button is so 90's :) I know there's a much easier way of doing this, but I'm not a iOS wiz, so this is what I have so far :)
 
NCbuzz
Code is Art
Profile
Posts: 575
Reg: Sep 11, 2013
Lillington, NC
11,100
like
02/18/15 06:52 PM (9 years ago)
Here is how I referenced a textField... ============================ I have a USC that has among other things, a textField (Named "txt_Name1"). I have a Save button that saves the screen data. In another plugin, I wanted to use that value so here is what I did: // after hitting save in USC screen // USC saved with: [BT_strings setPrefString:elementName valueOfPref:elementValue]; //To read it in another plugin, I added the following.... NSString *tmpTitle =[BT_strings getPrefString:@"txt_Name1"]; if ([tmpTitle length] > 0) { lblContact1.text = tmpTitle; lblContact1.textColor = [UIColor blackColor]; } else { lblContact1.text = @"Contact"; lblContact1.textColor = [UIColor whiteColor]; } Note the lblContact1 needed some additional code after creating the label .h added: IBOutlet UILabel *lblContact1; @property (nonatomic, retain) IBOutlet UILabel *lblContact1 .m added: @synthesize lblContact1; ======================== Hope that gives you some ideas. Still learning my way, and wish Chris would put out a short tutorial on this very subject.
 
NCbuzz
Code is Art
Profile
Posts: 575
Reg: Sep 11, 2013
Lillington, NC
11,100
like
02/18/15 06:58 PM (9 years ago)
Fingers Crossed- Just reread your post, that is a cool idea about using the itemID - Thanks! I was just wondering how to tell which element I was dealing with. (Have several copies of the same USC screen, where the names are incremented with a # at the end of their names.)- Think your idea will solve my current code issue.
 
Fingers Crossed
Veteran developer
Profile
Posts: 234
Reg: Jan 16, 2012
Simcoe, ON
6,390
like
02/18/15 07:58 PM (9 years ago)
When you click the element in the UI check out the window on the right. Heres a screen shot. http://postimg.org/image/lzpmlt8j1/ This (for me) is the label that I change when I select the stepper.
 
NCbuzz
Code is Art
Profile
Posts: 575
Reg: Sep 11, 2013
Lillington, NC
11,100
like
02/19/15 10:48 AM (9 years ago)
Right on! What I wound up doing was checking the start of the element name first. and the adding If Else loops. For example if I had several elements that started with 'score' (score_Won, score_Lost) grabbed those first, and the react differently to each as appropriate.
 

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.