Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 8    Views: 114

mrDavid
BTMods.com
Profile
Posts: 3936
Reg: May 21, 2011
San Diego, CA
51,910
01/14/14 03:36 PM (10 years ago)

BT30 - Day 11 - IF ELSE codes for specific screens

BT30 is my personal project to contribute to buzztouch: https://www.buzztouch.com/forum/thread.php?fid=2348BA49BA5737C92E3D9B5&tid=2348BA49BA5737C92E3D9B5 Day 11 - IF ELSE codes for specific screens ---------------------- DESCRIPTION ---------------------- This code is always fun to work with, if you have some code or idea that requires an IF THEN ELSE statement, you can plug this right in and alter it for how you would like it. You can thank @Chris1 and @Kittsy for the groundwork. So for this specific code, I altered the height of the header image (for a specific screen name only) on the menu with image plugin by plugging in (into the .m plugin file): /////////////////////////////////////////////////// NSString *thisItemNickname = [BT_strings getJsonPropertyValue:screenData.jsonVars nameOfProperty:@"itemNickname" defaultValue:@""]; /////////////////////////////////////////////////// and then replacing the line: imageHeight = 150; with this: /////////////////////////////////////////////////// if ([thisItemNickname isEqualToString:@"Contacts"]) { imageHeight = 0; } else { imageHeight = 150; } /////////////////////////////////////////////////// So with this code, only the screen menu with image named "Contacts" will resize the header image to 0 (removing it), but any other screens NOT named Contacts will have the regular size 150. This allows me to alter the plugin appearance for one screen without altering it for all menu with image screens. Very useful. Just change the "Contacts" name to whatever screen name you want to alter in your app and then use the if code to add your own custom values (in whatever plugin .m file you like to alter): /////////////////////////////////////////////////// if ([thisItemNickname isEqualToString:@"Contacts"]) { YOUR CODE HERE } else { YOUR CODE HERE } /////////////////////////////////////////////////// Hope this helps someone. David.
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
01/14/14 03:44 PM (10 years ago)
Always good stuff! :) Cheers! -- Smug
 
ictguy
Aspiring developer
Profile
Posts: 564
Reg: Jun 17, 2011
Mildura, Austra...
15,840
like
01/14/14 04:22 PM (10 years ago)
Thanks for sharing once again! I've been back through all the BT30 days I've missed :) Cheers Darrel
 
tb
buzztouch Evangelist
Profile
Posts: 2050
Reg: Nov 03, 2011
Oxford
32,300
like
01/14/14 05:20 PM (10 years ago)
Would you be able to change the header image size if the user has a 4 inch iPhone, with this method.
 
mrDavid
BTMods.com
Profile
Posts: 3936
Reg: May 21, 2011
San Diego, CA
51,910
like
01/14/14 05:28 PM (10 years ago)
Of course, stuff like: http://stackoverflow.com/questions/10167221/ios-detect-if-user-is-on-an-ipad Or try... if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) { CGRect screenBounds = [[UIScreen mainScreen] bounds]; if (screenBounds.size.height == 568) { //For iPhone5 } else { //for iPhone4 and all other } Then just include a "and" statement to include the detection of the screen code above I provided. Cheers, David
 
Arubaman
Aspiring developer
Profile
Posts: 636
Reg: Oct 20, 2011
Akron
16,910
like
01/16/14 12:26 AM (10 years ago)
Thanks this helps, still want to code a plugin.
 
Patrickmotox
Aspiring developer
Profile
Posts: 89
Reg: Dec 10, 2013
Cameron Park, C...
7,090
like
01/18/14 08:22 PM (10 years ago)
Once again. Thank you!
 
mrDavid
BTMods.com
Profile
Posts: 3936
Reg: May 21, 2011
San Diego, CA
51,910
like
01/30/14 03:39 PM (10 years ago)
@Arubaman You can do it! Come to the BT meetings, super useful.
 
NCbuzz
Code is Art
Profile
Posts: 575
Reg: Sep 11, 2013
Lillington, NC
11,100
like
04/10/14 07:37 PM (10 years ago)
Thanks! Note: Found to make this work, the "self" needed to be added to the code below in my app: NSString *thisItemNickname = [BT_strings getJsonPropertyValue:self.screenData.jsonVars nameOfProperty:@"itemNickname" defaultValue:@""];
 

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.