Discussion Forums  >  Config Data, JSON, App Refresh

Replies: 3    Views: 179

Ivan Haentjens
Code is Art
Profile
Posts: 8
Reg: Jul 21, 2011
Antwerp, Belgiu...
80
11/26/12 06:19 AM (13 years ago)

loadScreenObject not working: solved!

Hello, I'm trying to use the loadScreenObject on a button, but it leads to a blank screen is there something wrong with my code? { "itemId":"8CC09F67681B8BF416F38BA2", "itemType":"BT_buttonItem", "loadScreenWithItemId":"", "loadScreenWithNickname": "", "loadScreenObject":{"itemId":"B6AEFE7CB021CB82576B711", "itemType":"BT_screen_customURL", "itemNickname":"Google", "navBarTitleText":"test", "dataURL":"http://www.google.com", "forceRefresh":"1"}, "titleText":"objectG", "imageNameSmallDevice":"doctor.jpg", "imageNameLargeDevice":"doctor.jpg" } however, this works: { "itemId":"8CC09F67681B8BF416F38BA", "itemType":"BT_buttonItem", "loadScreenWithItemId":"B6AEFE7CB021CB82576B711", "titleText":"doctor4", "imageNameSmallDevice":"doctor.jpg", "imageNameLargeDevice":"doctor.jpg" } the xcode output for the first code: BT_viewControllerManager: the screen to load is nickname: "(null)" itemId: (null) itemType: (null) tx. Ivan
 
David @ buzztouch
buzztouch Evangelist
Profile
Posts: 6866
Reg: Jan 01, 2010
Monterey, CA
78,840
like
11/26/12 10:58 AM (13 years ago)
Stepping away for a bit but I'll give this a shot. The loadScreenObject you're creating in the JSON does appear valid so this isn't the issue. You're using buttons so I'll assume you're trying to do this while a BT_screen_buttons view controller is displaying. A button screen. Cool. There are two methods in this file that come into play when you tap a button. In the BT_screen_buttons.m file... 1) menuItemTap on line 572 ...This fires first, as soon as you tap a button 2) launchScreen on line 592 ...this is fired a few milliseconds later to launch the actual screen. The idea is that the button doesn't launch the screen immediately because it does a nifty little fade animation first. So, button tap, button fades, screen launches. This means we need to look at the launchScreen method. Have a look at this, starting on line 598 or so where it looks at the JSON data for the button that was tapped. You'll see where it's looking for a loadScreenItemId. It's not looking for a loadScreenNickname or a loadScreenObject. Ahhhh, this should be updated in this plugin! The BT_screen_menuList.m file looks for all three things (screen id, nickname, or object) to allow a little more flexibility. Like I said, this should be updated in the button plugin...and I'll get to that. But, in the meantime, you'll need to hack around a bit to modify your BT_screen_buttons.m file. Just look at the existing logic in the BT_screen_menuList.m file's didSelectRowAtIndexPath method on line 354. It looks for id, nickname, object, etc. You can cut-paste the same logic in your screen's launchScreen method. Hope this helps. And, GREAT FIND, we should have fixed this a long time ago! LOL.
 
Ivan Haentjens
Code is Art
Profile
Posts: 8
Reg: Jul 21, 2011
Antwerp, Belgiu...
80
like
11/26/12 11:42 AM (13 years ago)
Thank you! I'll try to fix it this way. Or wait for the experts' plugin update :-)
 
Ivan Haentjens
Code is Art
Profile
Posts: 8
Reg: Jul 21, 2011
Antwerp, Belgiu...
80
like
11/27/12 04:28 AM (13 years ago)
It works. Thank you. Let me share the reworked code for BT_screen_menuButtons.m at line 591 //launch screen -(void)launchScreen:(BT_item *)theMenuItem{ //appDelegate unidi1_appDelegate *appDelegate = (unidi1_appDelegate *)[[UIApplication sharedApplication] delegate]; //get the itemId of the screen to load NSString *loadScreenItemId = [BT_strings getJsonPropertyValue:theMenuItem.jsonVars:@"loadScreenWithItemId":@"0"]; //get possible nickname of the screen to load NSString *loadScreenNickname = [BT_strings getJsonPropertyValue:theMenuItem.jsonVars:@"loadScreenWithNickname":@""]; //use the id of the screen we want to load to get it's data object from the app //BT_item *screenObjectToLoad = [appDelegate.rootApp getScreenDataByItemId:loadScreenItemId]; //BT_viewControllerManager will launch the next screen //[BT_viewControllerManager handleTapToLoadScreen:[self screenData]:theMenuItem:screenObjectToLoad]; //bail if load screen = "none" if([loadScreenItemId isEqualToString:@"none"]){ return; } //check for loadScreenWithItemId THEN loadScreenWithNickname THEN loadScreenObject BT_item *screenObjectToLoad = nil; if([loadScreenItemId length] > 1){ screenObjectToLoad = [appDelegate.rootApp getScreenDataByItemId:loadScreenItemId]; }else{ if([loadScreenNickname length] > 1){ screenObjectToLoad = [appDelegate.rootApp getScreenDataByNickname:loadScreenNickname]; }else{ if([theMenuItem.jsonVars objectForKey:@"loadScreenObject"]){ screenObjectToLoad = [[BT_item alloc] init]; [screenObjectToLoad setItemId:[[theMenuItem.jsonVars objectForKey:@"loadScreenObject"] objectForKey:@"itemId"]]; [screenObjectToLoad setItemNickname:[[theMenuItem.jsonVars objectForKey:@"loadScreenObject"] objectForKey:@"itemNickname"]]; [screenObjectToLoad setItemType:[[theMenuItem.jsonVars objectForKey:@"loadScreenObject"] objectForKey:@"itemType"]]; [screenObjectToLoad setJsonVars:[theMenuItem.jsonVars objectForKey:@"loadScreenObject"]]; } } } //load next screen if it's not nil if(screenObjectToLoad != nil){ [BT_viewControllerManager handleTapToLoadScreen:[self screenData]:theMenuItem:screenObjectToLoad]; }else{ //show error alert [BT_debugger showIt:self:[NSString stringWithFormat:@"%@",NSLocalizedString(@"menuTapError",@"The application doesn't know how to handle this action?")]]; } }
 

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.