ZXing problem when find qr code that does not know - iphone

I have a question ...
I am using ZXing lib to recognize two types of QRCode (for
iphone application)
everything works fine ....
I use this method to analyze the results:
- (void)zxingController:(ZXingWidgetController*)controller didScanResult:(NSString *)result {
if([result isEqualToString:#QRCODERESULT_TYPPE_01])
{
...CASE 01
}
else if([result isEqualToString:#QRCODERESULT_TYPPE_02])
{
... CASE 02
}
}
This code works fine if I find a QRCode type 01 or 02 but when I try with another QRCode not know the controller is still some green squares ...
how can I reset the controller when it reads a QRCode I do not care?
txy

Dismiss the qr scanning controller regardless of whether the scanned QR code is the one you want or not.
- (void)zxingController:(ZXingWidgetController*)controller
didScanResult:(NSString *)result {
// always dismiss the qr controller
[self dismissModalViewControllerAnimated:NO];
if (qr code is of type 1) {
// do something if qr 1
}
else if (qr code is of type 2) {
// do something with qr 2
}
}

Related

set flash not working in zxing scanner library

can u show the full code for button on click method for toggle turn on/off flash when scan? I have try this, but not working, Im using
val mScannerView = object : ZXingScannerView(this) {
override fun createViewFinderView(context: Context?): IViewFinder {
return CustomViewFinderView(context!!)
}
}
btn.setOnclickListener{
if(flashStatus){
mScannerView.setFlash(true)
}else{
mScannerView.setFlash(false)
}
thanks

Issue in ionic 3 navigation on ios emulator

I have tried below 3 types of nav methods to move from Page A to Page B. When I generate a apk any one of this are working fine. But when I tried to emulate this in IOS none are working. I have used breakpoints in developer tools there is no error. Just nothing happens.
// this.nav.setRoot(pagename,{},{direction:"back"});
//this.nav.setRoot(pagename).then(() => {
this.nav.popToRoot();
});
// this.nav.push(pagename);
This is complete function.
openPage(page){
let nav = this.app.getActiveNavs()[0];
let activeView = nav.getActive();
if (activeView.name != page) {
if(page == "editCustomer"){
this.openEditCustomerModal();
} else if(page == "feedBackPage"){
this.openRatingModal();
}else{
this.nav.setRoot(page,{},{direction:"back"});
}
this.closeMenu();
}else{
this.menuCtrl.close();
}
}

Titanium_iphone contacts

I am trying to list contacts with Titanium. WOrks on android device, but on iphone simulator doesn't return anything.
var contacts= Ti.Contacts.getAllPeople();
alert("contacts.length");
returns 0. I am not sure what am i missing here.
Make sure that you have contacts created on your iOS simulator:
Use Home button (CMD+Shift+H) to go to dashboard.
Open up Contacts app
Create few contacts which you want to retrieve in your app.
Also before you call Ti.Contacts.getAllPeople() you have to request authorisation to contact list. Try code below:
function processContacts() {
Ti.API.info('authorized');
var contacts = Ti.Contacts.getAllPeople();
Ti.API.info(contacts.length);
}
if (Ti.Contacts.contactsAuthorization == Ti.Contacts.AUTHORIZATION_AUTHORIZED){
processContacts();
} else if (Ti.Contacts.contactsAuthorization == Ti.Contacts.AUTHORIZATION_UNKNOWN){
Ti.Contacts.requestAuthorization(function(e){
if (e.success) {
processContacts();
} else {
Ti.API.info('disallowed');
}
});
} else {
Ti.API.info('disallowed');
}
One last thing, in your code you wrote: alert("contacts.length") which will always display dialog view with "contacts.length" as a string, not value. To call it properly you should write: alert(contacts.length) without double quotes.

iPhone unit testing for viewController

I have a controller class in which i want to write the test case for the code which executed on the button click .In my testClass.m file i have following code from which i want to call the button from testClass.m . will this code work??
-(void)testcheckTheArrayForNull
{
viewController.temp=#"c";
viewController.buttonCount=1;
[viewController goButton:self];
STAssertNotNil(viewController.setUpArray,#"set up Array is not nil");
}
By this code will my control transfer to goButton???
I would say this could work, but you didn't provide code for goButton, setUpArray and I have no idea what temp or buttonCount do - so just guessing.

PhoneGap ChildBrowser Executing JavaScript

I wonder if this is possible to execute JavaScript inside phonegap childbrowser window so we can manipulate websites under phonegap app?
Looking at the big picture as one can create a function in Objective-C which executes that JS into childbrowser (modifying childbrowser.m and childbrowser.h files) and creating JS wrapper of it so one can call JS function to execute JS inside childbrowser.
I want you to modify ChildBrowser for me to have that functionality so I shouldn't lost doing it. At least give me initial steps.
Alright I just tried and it worked in a single go. That was amazing! I just modified ChildBrowser plugin of PhoneGap and it worked.
UPDATED
I finally got few minutes to update the answer for those who will encounter the same issue.
ChildBrowserCommand.h
- (void) jsExec:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;
ChildBrowserCommand.m
- (void) jsExec:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options; {
[childBrowser executeJS:(NSString *)[arguments objectAtIndex:0]];
}
ChildBrowserViewController.h
- (void)executeJS:(NSString *)js;
ChildBrowserViewController.m
- (void) executeJS:(NSString *)js {
[webView stringByEvaluatingJavaScriptFromString:js];
}
ChildBrowser.js
/* MIT licensed */
// (c) 2010 Jesse MacFadyen, Nitobi
function ChildBrowser()
{
}
// Callback when the location of the page changes
// called from native
ChildBrowser._onLocationChange = function(newLoc)
{
window.plugins.childBrowser.onLocationChange(newLoc);
}
// Callback when the user chooses the 'Done' button
// called from native
ChildBrowser._onClose = function()
{
window.plugins.childBrowser.onClose();
}
// Callback when the user chooses the 'open in Safari' button
// called from native
ChildBrowser._onOpenExternal = function()
{
window.plugins.childBrowser.onOpenExternal();
}
// Pages loaded into the ChildBrowser can execute callback scripts, so be careful to
// check location, and make sure it is a location you trust.
// Warning ... don't exec arbitrary code, it's risky and could cause your app to fail.
// called from native
ChildBrowser._onJSCallback = function(js, loc)
{
// Not Implemented
window.plugins.childBrowser.onJSCallback(js, loc);
}
/* The interface that you will use to access functionality */
// Show a webpage, will result in a callback to onLocationChange
ChildBrowser.prototype.showWebPage = function(loc)
{
PhoneGap.exec("ChildBrowserCommand.showWebPage",loc);
}
// close the browser, will NOT result in close callback
ChildBrowser.prototype.close = function()
{
PhoneGap.exec("ChildBrowserCommand.close");
}
// Not Implemented
ChildBrowser.prototype.jsExec = function(jsString)
{
// Not Implemented!!
PhoneGap.exec("ChildBrowserCommand.jsExec", jsString);
}
// Note: this plugin does NOT install itself, call this method some time after deviceready to install it
// it will be returned, and also available globally from window.plugins.childBrowser
ChildBrowser.install = function()
{
if(!window.plugins)
{
window.plugins = {};
}
window.plugins.childBrowser = new ChildBrowser();
return window.plugins.childBrowser;
}
My global variable.
var CB = null;
On my DeviceReady event.
CB = ChildBrowser.install();
if (CB != null) {
CB.onLocationChange = onCBLocationChanged;
}
I can execute any JS into webpage using.
CB.jsExec("alert('I am from ChildBrowser!');");
I hope my contribution to this will bring smile on your face.