使用下面的代碼,問題是我有兩個按鈕和兩個文本框,但我使用單一方法獲取qrcode值。我怎樣才能使用它的兩個文本域iPhone通過單一方法獲取兩個不同文本框的值
- (IBAction) keyScanButtonTapped
{
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
deviceKey.text = symbol.data;
// 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];
}
也許這只是我,但這個問題似乎沒有任何意義。我建議你提高你的原始問題的進一步細節。在哪個序列中應該發生什麼? – Till 2011-12-27 16:23:53
查看規範 - 操作方法接受一個參數,該參數是觸摸按鈕的指針。將它與鏈接到它的兩個按鈕進行比較,以查看哪一個被觸摸。 – 2011-12-27 16:26:56