Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 8    Views: 96

chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
02/05/13 05:22 PM (12 years ago)

iOS how-to: load a screen different from any of your tabs on startup

This was a question posed by Cyrus that I solved over email. Figured I'd share it here for anyone who might be interested. The question is, how do I load a screen that's not associated with any of my "tabs" when the app first starts up? This is different from a splash screen, in that it can be any type of plugin (i.e., custom url, etc). Here's the solution - keep in mind that you won't be able to get back to this screen after you click on a tab, unless you add some custom code in the navigation controller or have a link to that screen on some other menu. But, here you go: In your BT_application.m file, look for an if/then check near the very bottom of the file that looks like this: //if we have tabs..(something seriously wrong if we don't!) if([tmpViewControllers count] > 0){ //select first tab [rootTabBarController setSelectedIndex:0]; //fire the viewWillAppear method in the selected tab [rootTabBarController.navigationController viewWillAppear:NO]; } Now, add the following code after [rootTabBarController setSelectedIndex:0]; : myslideout_appDelegate *appDelegate = (myslideout_appDelegate *)[[UIApplication sharedApplication] delegate]; BT_item *screenObjectToLoad = nil; screenObjectToLoad = [appDelegate.rootApp getScreenDataByItemId:@"DAF22F0EC7AF04732DB4ABC"]; [BT_viewControllerManager handleTapToLoadScreen:screenObjectToLoad:screenObjectToLoad:screenObjectToLoad]; Of course, you'll need to replace the itemID above (DAF22F0EC7AF04732DB4ABC) with the itemID of whatever screen you want to display.
 
ictguy
Aspiring developer
Profile
Posts: 564
Reg: Jun 17, 2011
Mildura, Austra...
15,840
like
02/05/13 05:27 PM (12 years ago)
Thanks Chris, Great info for developers! It would also be nice to set a value somewhere so you could only show the screen once. Like an instructions screen that would only ever show once ... just a thought. cheers Darrel
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
02/05/13 07:09 PM (12 years ago)
Ah yes - you're referring to the plugin I'm planning...
 
ictguy
Aspiring developer
Profile
Posts: 564
Reg: Jun 17, 2011
Mildura, Austra...
15,840
like
02/05/13 07:40 PM (12 years ago)
Good one ... looking forward to it!
 
Stobe
buzztouch Evangelist
Profile
Posts: 1528
Reg: Mar 04, 2011
Fredericksburg,...
24,680
like
02/05/13 09:20 PM (12 years ago)
And for completeness, don't forget to replace this: myslideout_appDelegate with : yourprojectname_appDelegate each place that it appears in the above code.
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
02/05/13 09:21 PM (12 years ago)
Oh yea - good catch Stobe!
 
ianJamesPiano
Code is Art
Profile
Posts: 2661
Reg: Feb 13, 2011
Palm Springs, C...
37,010
like
02/05/13 11:25 PM (12 years ago)
I like it!
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
02/05/13 11:49 PM (12 years ago)
For robustness, reference the Screen's Nickname instead of it's ID. I am not near the Computer, replace getScreenDataByItemId with xxxx?xxxx -- Niraj
 
Cyrus_8888
I hate code!
Profile
Posts: 151
Reg: Dec 24, 2011
Sydney
1,610
like
02/06/13 04:49 AM (12 years ago)
Hi Chris, Thanks for your help once again! Further more, the main purpose is to display animated background images by using custom URL screen assign to be the homescreen. It would be much appreciated if someone could share their knowledge on how to add a custom code in the navigation controller and link those screen back to home. Cheers Cyrus
 

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.