大家好,我的项目遇到了一些问题。 我制作了一个QR e阅读器,它将扫描一个条形码,然后在我的网站上搜索结果,但在扫描6x我的应用程序崩溃后,我希望有人可以帮助我。
我是Objective-C和iPhone SDK的新手,但我真的需要这个项目,谢谢。
AppDelegate.h
#import <UIKit/UIKit.h>
@class ViewController;
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) ViewController *viewController;
@end
ViewController.h
#import <UIKit/UIKit.h>
#import "ZBarSDK.h"
@interface ViewController : UIViewController<ZBarReaderDelegate> {
IBOutlet UIWebView *myWeb;
IBOutlet UITextView *resultTextView;
}
- (IBAction)startScanning:(id)sender;
@end
ViewController.m
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
#pragma mark - ViewController's LifeCycle methods
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
#pragma mark - Button click method
- (IBAction)startScanning:(id)sender {
ZBarReaderViewController *codeReader = [ZBarReaderViewController new];
codeReader.readerDelegate=self;
codeReader.supportedOrientationsMask = ZBarOrientationMaskAll;
ZBarImageScanner *scanner = codeReader.scanner;
[scanner setSymbology: ZBAR_I25 config: ZBAR_CFG_ENABLE to: 0];
[self presentViewController:codeReader animated:YES completion:nil];
}
#pragma mark - ZBar's Delegate method
- (void) imagePickerController: (UIImagePickerController*) reader didFinishPickingMediaWithInfo: (NSDictionary*) info
{
// get the decode results
id<NSFastEnumeration> results = [info objectForKey: ZBarReaderControllerResults];
ZBarSymbol *symbol = nil;
for(symbol in results)
// just grab the first barcode
break;
NSString *myString = [NSString stringWithFormat:@"http://www.northland-cc.com/%@", symbol.data];
NSURL *url = [NSURL URLWithString:myString];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[myWeb loadRequest:requestObj];
// dismiss the controller
[reader dismissViewControllerAnimated:YES completion:nil];
}
@end