Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 11    Views: 58

Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
02/13/14 01:36 PM (11 years ago)

Going to a different view from XIB

This should be one of the basics, but is actually something I could never wrap my head around, which I think prevents me from learning Objective C in the first please... which is why I love buzztouch so much... BUT... I'm using a plugin in one of my apps which has an xib file. The plugin functions correctly, but I need to add a button in the view of the xib that goes to another screen. For everything else, I use the HTML pro plugin in this situation, but this time I can't because I need the functionality of this particular plugin on that screen. o, I'd probably start with drawing a label with a background image of my button (or simply draw an image on the xib instead), but I've been spoiled using buzztouch, and don't know how to to tell that label or image to load, say, one of my custom html screens when tapped. I know, it's probably the first thing people learn with objective C... but I have no idea how to do it, lol. I miss the days of VB 6.0... Screen2.load, Screen1.close. lol
 
ATRAIN53
Code is Art
Profile
Posts: 1755
Reg: Nov 17, 2011
Chicago
26,450
like
02/13/14 02:33 PM (11 years ago)
You can do this 2 ways very easily: 1) the BT way - which would be creating a button on the XIB and then using [self loadScreenWithItemId:@"put your BT screen item id here"]; when the button is clicked. 2) the ObjC way which is to Manually Instantiate a ViewController and then push it onto the stack. that code would look like this: UIViewController * vc = [[UIViewController alloc] init]; [self presentViewController:vc animated:YES completion:nil];
 
Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
like
02/13/14 02:36 PM (11 years ago)
Perfect Atrain, exactly what I needed. I'll probably go the BT way. Once I draw the button though, where do I put the code above so that xcode knows when to fire it when the button is pressed? Sorry, I suck at Objective C/Xcode, lol.
 
ATRAIN53
Code is Art
Profile
Posts: 1755
Reg: Nov 17, 2011
Chicago
26,450
like
02/13/14 02:57 PM (11 years ago)
I used to suck at this as well but learned by studying other code that did similar stuff to what I was trying to accomplish and then testing and failing until I got the result I wanted. Essentialy that button is triggering an "IBAction" when you click it. Look at the BT_plugin_success sample plugin that should be in your project, that has a really nice example of all the code to do something like this. Inside that wobble method is where you'd put that [self loadScreenWithItemId:@"put your BT screen item id here"];
 
Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
like
02/13/14 03:06 PM (11 years ago)
Worked perfectly, thanks ATRAIN! I simply created the IBaction as you stated, and control clicked it while dragging it to the files owner in the xib. :)
 
EdReyes
Lost but trying
Profile
Posts: 574
Reg: Oct 21, 2013
location unknow...
17,640
like
02/13/14 03:13 PM (11 years ago)
Learn something new everyday, thanks for the share.
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
02/13/14 08:42 PM (11 years ago)
yep - now you'll be able to create plugins with ease! :) Using xib's can be a fantastic way to create the design you want for any screen, and have it perform simple actions like loading a screen. I definitely suggest loading screens using the BT method that ATrain suggested. While the other way will "work" to load a screen, it loses out on any of the benefits Buzztouch gives you, such as control panel data. Plus, it's a lot simpler!
 
Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
like
02/13/14 10:46 PM (11 years ago)
"yep - now you'll be able to create plugins with ease!" @Chris1: I don't know if I'd go that far! lol. I probably need to learn a little objective C before I start making plugins ;) Hmmm.... I think I need "BuzzPlug"... the click and build plugin development system for people that don't know how to make plugins ;)
 
SmugWimp
Smugger than thou...
Profile
Posts: 6316
Reg: Nov 07, 2012
Tamuning, GU
81,410
like
02/14/14 01:24 AM (11 years ago)
This video went a long way in teaching me plugin creation. It's a bit fast paced, but it's a video; you can rewind it and go over parts again, while you have xcode open. https://www.youtube.com/watch?v=OJrMVTn8z0s I concur with Chris1… don't let something so trivial as 'not knowing how to program' keep you from creating a plugin. It's truly a matter of: • understanding 'logic'. This applies to *any* language. • a good understanding of search term creation and using google to drill down to specifics. • a willingness to watch something crash and burn, and be able to laugh while it's happening. The rest of it, once you see a few examples, will come. After that, it's just different scenarios filling in the gaps. Cheers! -- Smug
 
EdReyes
Lost but trying
Profile
Posts: 574
Reg: Oct 21, 2013
location unknow...
17,640
like
02/14/14 01:59 AM (11 years ago)
I have to admit I watched this 3 months ago and was totally lost. I guess because of the different xcode and ios versions just trying to find things, I gave up. Now after much training, I rewatched this video and everything is making sense. Time to start cracking out some awesome plugins. Lookout marketplace.
 
Angry Ninja
Aspiring developer
Profile
Posts: 1045
Reg: Aug 25, 2013
Maine
17,150
like
02/14/14 06:25 AM (11 years ago)
Maybe I'll give it a shot. Thanks for the video link. I program in several languages... objective C is just one I've always stumbled with. I assumed you would have to know it pretty well to create a plugin, but sounds like it may not be the case. I know enough objective C to modify things to get what I need done usually (with a lot of help from google and others), but not enough to write any code from scratch... not even close. I'm barely to the point where I can look at objective c code and recognize what it's accomplishing. Once I wrap up the app I'm working on, maybe I'll take a look at what it takes to do a plugin.
 
ATRAIN53
Code is Art
Profile
Posts: 1755
Reg: Nov 17, 2011
Chicago
26,450
like
02/14/14 08:05 AM (11 years ago)
Def give it a shot, you're well on your way.... I'd suggest learning simple things like this the proper way first following some basic tutorials out there (like Wenderlich's stuff). Then looking at the BT code - that's when you'll really understand the true power of what David has built into BT. His methods make no sense to newbies, they can't be researched anywhere except here. His subclassing of the UIViewcontroller to the BT_Viewcontroller is a difficult concept to understand. BT doesn't use Storyboards like everyone else does to build their navigation. The BT code did nothing but confuse me at first - until I understood how the code was supposed to work - and that's when I started to understand his custom BT methods and why he made them. He has peppered the source code with all kinds of great tidbits and notes, don't be afraid to study it. Duplicate a plugin and comment out his code and try your own methods in there. I spent a month trying various ways to get an xib file working in BT and even when David said they probably won't work, I found a way and the answer came from working thru another non BT tutorial. and this stuff works the SAME way in Android, so don't be buffaloed by it. Instead of loading a new viewcontroller you're loading a FRAGMENT Instead of an IBAction on that button, you're using an onClickListener to launch an INTENT The languages are more similar than you think - which is a key concept David makes in some of the Android training videos that the iOS Only folks are missing out by not watching them.
 

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.