Alex - 2012-12-05

Hey guys, Im trying really hard to get my app to scan a QR code and thereafter open the URL in the app itself and not in Safari…

I have read tons of sites etc etc etc… but I still cant get it to work… the annoying thing is that I dont get any errors still it doesnt work…

In my main project the coding looks like this…

.h

#import <UIKit/UIKit.h>
#import "WebView.h"

@interface ViewController : UIViewController <ZBarReaderDelegate, UIWebViewDelegate>

{
    UIImageView *resultImage;
    UIView *WebView;
    UIView *window;
   
}

@property (nonatomic, retain) IBOutlet UIImageView *resultImage;

- (IBAction) scanButtonTapped;

@end

in my .m

#import "ViewController.h"
#import "WebView.h"

@interface ViewController ()

@end

@implementation ViewController

@synthesize resultImage;

- (IBAction) scanButtonTapped
{
    // ADD: present a barcode reader that scans from the camera feed
    ZBarReaderViewController *reader = ;
    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 presentModalViewController: reader
                            animated: YES];
   
   
}

- (void) dealloc
{
    self.resultImage = nil; }

- (void)viewDidLoad

{
    ;

  }

- (BOOL) webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {return YES;}

- (void) webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
   
    ;
}

- (void) webViewDidFinishLoad:(UIWebView *)webView {

    ;
    window = nil;
   
}

- (void)didReceiveMemoryWarning
{
    ;
    // Dispose of any resources that can be recreated.
}

- (void) imagePickerController: (UIImagePickerController*) reader
didFinishPickingMediaWithInfo: (NSDictionary*) info
{
    // ADD: get the decode results
    id<NSFastEnumeration> results =
    ;
    ZBarSymbol *symbol = nil;
    for(symbol in results)
       
       
       
       
        // EXAMPLE: just grab the first barcode
        break;
   

   
   
    // EXAMPLE: do something useful with the barcode image
    resultImage.image =
    ;
   

   
 
 

}

-(void)openURL
{

    WebView *WVC = [ initWithNibName: @"WebView" bundle:nil];
    WVC.buy = ;
    ;

   
   
}
   

@end

i also created a new file so i got a new .h and .m and i also created a new xib that i called WebView…
in the new xib i put a viewcontroller and placed a uiwebview over it…

in my .h the following code is shown:

#import <UIKit/UIKit.h>

@interface WebView : UIViewController <UIWebViewDelegate>

{

    IBOutlet UIWebView *web;
    UIView *window;

}

@property (nonatomic, retain) IBOutlet NSString *buy;

@end

and in my .m i put…:

#import "WebView.h"
#import "ViewController.h"

@interface WebView ()

@end

@implementation WebView

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = ;
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    ;
   

   
    web.scalesPageToFit = YES;
    NSURLRequest *request = [ initWithURL:];
    ;
}

- (BOOL) webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {return YES;}

- (void) webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
   
    ;
}

- (void) webViewDidFinishLoad:(UIWebView *)webView {
   
    ;
    window = nil;
   
}

   

- (void)didReceiveMemoryWarning
{
    ;
    // Dispose of any resources that can be recreated.
}

@end

please guys this is my last step before im done :)
i had no problems whatsoever making the qr code url open in safari but i want everything to stay IN my app :(

so pleeeease help me :)
thanks u guys

Alex