Discussion Forums  >  Plugins, Customizing, Source Code

Replies: 14    Views: 203

mikoz
I hate code!
Profile
Posts: 51
Reg: Nov 14, 2010
Australia
3,610
04/10/13 10:59 PM (12 years ago)

BT_Screen_Blank plugin xib file for barcode scanner ZbarSDK

Hi BT Community, I have a need to install the ZbarSDK natively in my BT app, in the instructions @ http://zbar.sourceforge.net/iphone/sdkdoc/tutorial.html it says to open the .xib file? Knowing that BT doesnt use xib's I figured I would use the blank screen plugin and build one myself... eg.. BT_Screen_Blank.xib Question 1. After pulling a UIView onto the screen, creating a button, a UIImageView & a text box I then tried to pull a New referencing Outlet from View to the File's Owner and WHAM nothing? No popup no options no errors? The class for both is UIView, what have I missed? And where to from here to link back to my blank.h and .m files? Question 2. The documents reference "ReaderSampleViewController.h is that the equivalent in BT of BT_viewController.h cause I get nothing but errors whenever I paste anything in there referencing to both viewController.m and main.m? Question 3. Should I pursue this implementation or is it doomed from the get-go? Previously I have had some success implementing this method---> https://www.buzztouch.com/forum/thread.php?tid=A2E1C537F2255EAF28E2454&command=isSearching&currentPage=1&topicTitle=barcode&createdBy=&repliedBy=&minViews=-1&maxViews=-1&minReplies=-1&maxReplies=-1&forumCategory= But the idea of getting my app to open another app is but a novelty and not very professional. Thanks in advance. Mick
 
Dragon007
Lost but trying
Profile
Posts: 1509
Reg: Dec 17, 2011
London
20,590
like
04/11/13 02:58 AM (12 years ago)
Will be keeping an eye on this post as I would like to add a QR to my apps. If you solve this issue, please share on BT. Good luck! I'm sure someone will help.
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
04/11/13 05:14 AM (12 years ago)
Question 1 Have you added the custom class to the new xib. If not click files owner then on the other side press the 3 rd button and add BT_screen_blank as the class. You should now be able to connect to the .h file. Also don't forget to add the view as the view in files owner Question 2 We call them plugins the rest of the programming world calls them view controllers. ReaderSampleViewController.h in the tutorial is your BT_screen_blank.h file Question 3 Carry on. To be honest this is one of the easiest tutorials for integrating a third party sdk I have come across, you should have seen aurasmas pile of horse crap. P.s if you are using the new xcode you will need to remove the armv7s support in the target file
 
ATRAIN53
Code is Art
Profile
Posts: 1755
Reg: Nov 17, 2011
Chicago
26,450
like
04/11/13 06:51 AM (12 years ago)
Very Nice. That does look like a decent SDK and one that would be easy to drop in. Too bad they don't have an Android version. I have been tinkering with zxing because it works on Android, but I like this Zbar.... Smug just made a tutorial on how to do the XIB thing that has some pics you might find helpful: https://dl.dropboxusercontent.com/u/115208762/EZXibConnect.pdf Aurauma SDK, I'm still dragging frameworks into my project....LOL
 
mikoz
I hate code!
Profile
Posts: 51
Reg: Nov 14, 2010
Australia
3,610
like
04/11/13 01:58 PM (12 years ago)
@dragon007 I've been looking at this project and putting it off for over a year, now it WILL be sorted once and for all! I will definitely be seeing this through to an end on here. @kittsy, omfg thank you for such excellent answers! I added UIView as the custom class, I will try blank thanks. Why remove armv7? Is this SDK incompatible? @atrain53 I have played around with zxing widget, have you seen the new zxing iPhone port on GitHub? When I am back at my mac I will find the link to share with you. I had seen Smugs guide but was stuck at referencing outlets. Cheers
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
04/11/13 02:00 PM (12 years ago)
It mustn't be it will give you an error once it's loaded thought I'd give you the heads up
 
mikoz
I hate code!
Profile
Posts: 51
Reg: Nov 14, 2010
Australia
3,610
like
04/12/13 09:27 PM (12 years ago)
https://github.com/TheLevelUp/ZXingObjC Is the new zxing project written entirely in objectivec that I mentioned. If I have some success with zbar I will actively pursue this alternative also. Mick
 
mikoz
I hate code!
Profile
Posts: 51
Reg: Nov 14, 2010
Australia
3,610
like
04/15/13 12:04 AM (12 years ago)
For the life of me I can't seem to get my head around connecting the outlets? In my BT_screen_blank.h to the left of the @property's and IBOutlet I have these white circles, does that mean I have not linked these references? Ive changed the viewcontroller to BT_screen_blank for visuals. eg.. 8. Now we can finish the interface connections - open BT_screen_blank.xib and make these connections: Connect BT_screen_blank resultImage outlet to the ImageView. *(For the "files owner custom class" I have selected "BT_screen_blank" but resultimage does not show up anyplace I can find?) Connect BT_screen_blank resultText outlet to the TextView. *(Same here?) Connect BT_screen_blank scanButtonTapped action to the RoundedRectButton(Scan) event TouchUpInside. *(From first responder I can drag scanButtonTapped to the Actual "Scan" button and select Touch Up Inside. I hope that is at least on the right path?) Mick
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
04/15/13 12:23 AM (12 years ago)
I'll send you my class files later on you can compare what you've done. PM me your email
 
mikoz
I hate code!
Profile
Posts: 51
Reg: Nov 14, 2010
Australia
3,610
like
04/16/13 09:58 PM (12 years ago)
Hi all, Success! Without the help of @Kittsy I would be still stuck at "Connecting the Outlets" Here is the rundown from my perspective; //Build your app in BT presenting a "blank screen plugin" for the page you wish to have your scanner on. Download your source code and copy in your plugins folder as normal. Extend the plugins folder. Drag your downloaded "ZBarSDK" folder into the "bt_screen_blank" plugin folder. Keep the bt_screen_blank folder highlighted... //Create a BT_screen_blank.xib file in Xcode by clicking File, New - New File, (IOS/User Interface) "Empty" naming it appropriately. Open the xib file and follow the SDK instructions to lay it out. //Go to your targets, build phases tab and click the + to add the libraries required in the SDK. Whilst in that tab still select Compile Sources and add (+ Add Target) your BT_screen_blank.m file. And also under "Copy Bundle Resources" add (+ Add Target) your newly created .xib file. //Now that you are here, open your BT_screen_blank.h file and update it to look like this: #import <Foundation/Foundation.h> #import <UIKit/UIKit.h> #import "BT_viewController.h" #import "ZBarSDK.h" @interface BT_screen_blank : BT_viewController < ZBarReaderDelegate > { IBOutlet UIImageView *resultImage; IBOutlet UITextView *resultText; } @property (retain, nonatomic) IBOutlet UIImageView *resultImage; @property (retain, nonatomic) IBOutlet UITextView *resultText; - (IBAction)scanButtonTapped:(id)sender; @end //Now open your BT_screen_blank.m file and edit the #import BT_appDelegate.h reference to "yourappname_appDelegate.h & also within the "//view will appear" method, edit BT_appDelegate.h reference to "yourappname_appDelegate.h //Then directly under the #import statements put; @implementation BT_screen_blank @synthesize resultImage, resultText; After the //dealloc segment but right before @end paste; - (IBAction)scanButtonTapped:(id)sender { // ADD: present a barcode reader that scans from the camera feed ZBarReaderViewController *reader = [ZBarReaderViewController new]; reader.readerDelegate = self; reader.supportedOrientationsMask = ZBarOrientationMaskAll; ZBarImageScanner *scanner = reader.scanner; // TODO: (optional) additional reader configuration here // EXAMPLE: disable rarely used I2/5 to improve performance [scanner setSymbology: ZBAR_I25 config: ZBAR_CFG_ENABLE to: 0]; // present and release the controller [self presentViewController:reader animated:TRUE completion:nil]; [reader release]; } - (BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) interfaceOrientation { return(YES); } //Note that @Kittsy updated the "depreciated" presentmodalviewcontroller to support IOS6. (Thanks) //Now put directly in below that the next block to which I have modified to automatically use the resultText.text in a webview search. (Change the URL to whatever you want: presently google.com.au). - (void) imagePickerController: (UIImagePickerController*) reader didFinishPickingMediaWithInfo: (NSDictionary*) info { // ADD: get the decode results id<NSFastEnumeration> results = [info objectForKey: ZBarReaderControllerResults]; ZBarSymbol *symbol = nil; for(symbol in results) // EXAMPLE: just grab the first barcode break; // EXAMPLE: do something useful with the barcode data resultText.text = symbol.data; CGRect webFrame = CGRectMake(0.0, 0.0, 320.0, 460.0); UIWebView *webView= [[UIWebView alloc] initWithFrame:webFrame]; [webView setBackgroundColor:[UIColor whiteColor]]; NSString *urlAddress= @"http://www.google.com.au/search?q="; urlAddress =[urlAddress stringByAppendingString:resultText.text]; NSURL *url= [NSURL URLWithString:urlAddress]; NSURLRequest *requestObj= [NSURLRequest requestWithURL:url]; [webView loadRequest:requestObj]; [self.view addSubview:webView]; // ADD: dismiss the controller (NB dismiss from the *reader*!) [self dismissViewControllerAnimated:NO completion:nil]; } @end //Now onto Connecting your outlets in your BT_screen_blank.xib file; which I still can't figure out? So I may ask @Kittsy to chime in with this important little snippet that he has mastered... //And onto making the xib prettier!!!! Mick
 
mikoz
I hate code!
Profile
Posts: 51
Reg: Nov 14, 2010
Australia
3,610
like
04/16/13 10:13 PM (12 years ago)
This is what I think to do with the connections?? right click "View" on the left and drag a "new referencing outlet" to "File's Owner" select "view" when it pops up. right click "Button - Scan" on the left and drag "Touch up inside" to "File's Owner" select "scanButtonTapped" right click "Image View" on the left and drag a "new referencing outlet" to "File's Owner" select "resultImage" right click "Text View" on the left and drag a "new referencing outlet" to "File's Owner" select "resultText" AND SAVE your xib Mick
 
mikoz
I hate code!
Profile
Posts: 51
Reg: Nov 14, 2010
Australia
3,610
like
04/16/13 10:34 PM (12 years ago)
This is what I think to do with the connections?? right click "View" on the left and drag a "new referencing outlet" to "File's Owner" select "view" when it pops up. right click "Button - Scan" on the left and drag "Touch up inside" to "File's Owner" select "scanButtonTapped" right click "Image View" on the left and drag a "new referencing outlet" to "File's Owner" select "resultImage" right click "Text View" on the left and drag a "new referencing outlet" to "File's Owner" select "resultText" AND SAVE your xib Mick
 
ATRAIN53
Code is Art
Profile
Posts: 1755
Reg: Nov 17, 2011
Chicago
26,450
like
04/17/13 06:43 AM (12 years ago)
Very cool, you're in great hands. Those steps sound about right. IB is very multi functional. If you use the assistant editor it will even write code for you. Amazing tool. Tons of great vids to teach you how to use it. Well worth the time, it's how I learned we needed to be able to use these in BT! Glad I figured it out and got David on board to use them. No better way to drag elemenst and arrange them on a screen. Spending so much time using the Android 'equivelant' now, I miss IB. I looked at the SDK and they had a nice sample app. It looked pretty basic- Once it scanned the code, it just displayed the results and then....? So this part here is what I was trying to figure out next: // EXAMPLE: do something useful with the barcode data resultText.text = symbol.data; You could do just about anything..... You are searching Google with the result string?
 
Kittsy
buzztouch Evangelist
Profile
Posts: 2251
Reg: Feb 22, 2012
Liverpool
31,360
like
04/17/13 08:07 AM (12 years ago)
The screen I made was you make the qrcode text and set it as your screenID then as soon as the code is scanned it loads the screen. If you gave bought the voucher plugin just copy the code and swap the text box line to the symbol.data
 
mikoz
I hate code!
Profile
Posts: 51
Reg: Nov 14, 2010
Australia
3,610
like
04/17/13 01:52 PM (12 years ago)
I just used google in my example as there is an immediate result for multiple people, I will be using it to query a table and build the html in Wordpress for a store. The catalogue contains the qrcodes. Mick
 

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.