Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 18    Views: 85

Antonios
Apple Fan
Profile
Posts: 381
Reg: Feb 12, 2013
Korinthos, Gree...
4,610
03/23/13 08:40 AM (12 years ago)

Adding xib files to bt screens

Hello guys, I wonder if there is a way of importing xib files inside a bt_screen and how we call it? for example a button menu from the home screen that can show the xib file?
 
SheriDee
Code is Art
Profile
Posts: 1094
Reg: Sep 23, 2011
location unknow...
22,840
like
03/23/13 09:31 AM (12 years ago)
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
03/23/13 09:31 AM (12 years ago)
There's at least a couple ways of doing this, but here's how I did it in my latest plugin: In the .m file, override the init method and also implement the initwithnib method. From the init method send a return value equal to the initwithnib method
 
Antonios
Apple Fan
Profile
Posts: 381
Reg: Feb 12, 2013
Korinthos, Gree...
4,610
like
03/23/13 09:45 AM (12 years ago)
thank you guys…No I haven't tried these plugins but I'll sure do now. I see there is a .xib file in them so I'll learn how to deal with them, form their code… I'll definitely watch David's video @chris I don't fully understand what you say, I'm not too familiar obviously :(
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
03/23/13 10:37 AM (12 years ago)
Sorry - that's what I get for trying to answer questions on my phone! Next time I'm at my computer I'll try to draft some code if you haven't figured it out by then
 
Antonios
Apple Fan
Profile
Posts: 381
Reg: Feb 12, 2013
Korinthos, Gree...
4,610
like
03/23/13 10:39 AM (12 years ago)
plz do it whenever you can…An don't ask for sorry…Are you kidding? If there weren't guys like you, we possibly couldn't have done anything!!!
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
03/23/13 10:43 AM (12 years ago)
Well thanks-I was totally clueless last August when I joined Buzztouch. Find some of my early posts and you'll see what I mean!
 
Antonios
Apple Fan
Profile
Posts: 381
Reg: Feb 12, 2013
Korinthos, Gree...
4,610
like
03/23/13 10:44 AM (12 years ago)
hehehehe this gives me hopes for the best
 
mutzy
Aspiring developer
Profile
Posts: 841
Reg: Nov 03, 2010
Medford, MA
9,860
like
03/23/13 11:16 AM (12 years ago)
I was in the same boat as you a few months ago, wanted to create my own xib screens. The video Sheri posted is a great place to start! I've since made several plugins using xib but most aren't really useful to others. I did turn one into a plugin for others... the XIB button menu plugin. I am not a coder my any means, actually I spend most of my days in the emergency room, so took awhile for me to figure out how to make buttons click, connect them to other screens, etc. This plugin takes care of it for you. Even if you want the buttons to do something other than open other BT screens it'll give you an idea of how the code works. Hope that helps! josh
 
Antonios
Apple Fan
Profile
Posts: 381
Reg: Feb 12, 2013
Korinthos, Gree...
4,610
like
03/23/13 12:56 PM (12 years ago)
thanks josh for the help…I'm planning of purchasing your plugin in the coming days, that's for sure…my only thought is that it can be used only once… anyway thanks for the support…I'll let you know when I'm going to need your help…Keep up the good work! :)
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
03/23/13 04:40 PM (12 years ago)
Okay - here's some code to try out. In your .m file that you want to load the xib file, add these two methods: - (id)initWithScreenData:(BT_item *)theScreenData { [super initWithScreenData:theScreenData]; NSLog(@"initializing"); BT_appDelegate *appDelegate = [[BT_appDelegate alloc]init]; if ([appDelegate.rootApp.rootDevice isIPad]) { return [self initWithNibName:@"Cr_voteCandidate~ipad" bundle:nil]; } else { return [self initWithNibName:@"Cr_voteCandidate" bundle:nil]; } } - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; NSLog(@"setting up nib file"); if (self) { // Custom initialization } return self; }
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
03/23/13 04:42 PM (12 years ago)
You could probably even combine those two methods, but that makes it a little more clear to other developers what is going on. Also, if you're entering this into a current project (and not a plugin source code), you'll need to change the two "BT_appDelegate" references to "[yourAppName]_appDelegate"
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
03/23/13 04:44 PM (12 years ago)
oh yeah - also, change the "Cr_voteCandidate" and "Cr_voteCandidate~ipad" entries to the names of your xib files
 
Antonios
Apple Fan
Profile
Posts: 381
Reg: Feb 12, 2013
Korinthos, Gree...
4,610
like
03/23/13 06:30 PM (12 years ago)
ok…should I put the rest of the code as it is? just copy and paste? and only change "Cr_voteCandidate" and "Cr_voteCandidate~ipad" entries to the names of my xib files?
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
03/23/13 06:59 PM (12 years ago)
Yep - and maybe the appDelegate like I mentioned
 
Antonios
Apple Fan
Profile
Posts: 381
Reg: Feb 12, 2013
Korinthos, Gree...
4,610
like
03/23/13 08:02 PM (12 years ago)
thank you chris…your help is so appreciated!!!
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
03/23/13 08:04 PM (12 years ago)
no prob - hope it works for you :)
 
Dragon007
Lost but trying
Profile
Posts: 1509
Reg: Dec 17, 2011
London
20,590
like
04/01/13 09:49 AM (12 years ago)
Sorry, I'm late to this post, but is this code that Chris has supplied, best suited to the blank screen plugin?
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
04/01/13 09:53 AM (12 years ago)
You could do it that way, or just create a new class file
 

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.