使用下面的代碼,但我沒有得到結果的文本框的值...任何幫助文本框的值的問題iPhone
-(IBAction) scanButtonTapped:(id)sender
{
int button = [sender tag];
if (button == 1) {
NSLog(@"ID Button Pressed");
deviceID.text = result;
}
else if (button == 2){
NSLog(@"Key button Pressed");
deviceKey.text = result;
}
NSLog(@"TBD: scan barcode here...");
// 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 presentModalViewController: reader animated: YES];
[reader release];
}
-(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
result = symbol.data;
NSLog(@"result = %@",result);
// EXAMPLE: do something useful with the barcode image
resultImage.image =
[info objectForKey: UIImagePickerControllerOriginalImage];
// ADD: dismiss the controller (NB dismiss from the *reader*!)
[reader dismissModalViewControllerAnimated: YES];
}
你剛纔談到的第一個函數'deviceID'和'deviceKey'文本字段? – 2011-12-29 06:10:33
是的,我正在談論deviceID和deviceKey文本域 – AppDeveloper 2011-12-29 06:21:22
你有適當的網點連接? 'NSLog'是否打印正確的值? – Ilanchezhian 2011-12-29 06:21:31