【发布时间】:2011-03-10 12:06:00
【问题描述】:
我在按下按钮时使用的是二维码 SDK,它会有一个 presentModalView 我有一个信息按钮。我希望它链接到另一个笔尖以显示有关它如何工作的信息!
-(IBAction)QRscan;
{
//Make sure we can even attempt barcode recognition, (i.e. on a device without a camera, you wouldn't be able to scan anything).
if([SKScannerViewController canRecognizeBarcodes])
{
SKScannerViewController *scannerVC = [[SKScannerViewController alloc] init]; //Insantiate a new SKScannerViewController
scannerVC.delegate = self;
scannerVC.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(cancelTapped)];
UIButton *button = [UIButton buttonWithType:UIButtonTypeInfoLight];
[button addTarget:self action:@selector(settingsTapped) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *infoItem = [[UIBarButtonItem alloc] initWithCustomView:button];
scannerVC.navigationItem.rightBarButtonItem = infoItem;
scannerVC.title = @"Scan a QRcode";
qrtest.text = @""; //Reset our info text label.
scannerVC.shouldLookForQRCodes = YES;//QRCode Checker
UINavigationController *_nc = [[[UINavigationController alloc] initWithRootViewController:scannerVC] autorelease]; //Put our SKScannerViewController into a UINavigationController. (So it looks nice).
[scannerVC release];
[self presentModalViewController:_nc animated:YES]; //Slide it up onto the screen.
}
- (void) settingsTapped {
qrcode_info *otherVC = [[qrcode_info alloc] initWithNibName:@"qrcode_info" bundle:Nil ];
[self presentModalViewController: otherVC animated:YES];
[otherVC release];
}
【问题讨论】:
-
问题/疑问是什么?有什么例外吗?
-
到底是什么问题?我还注意到您有一个额外的分号,可能会导致编译器错误:-(IBAction) QRScan;
-
我展示了一个用于扫描二维码的presentmodalviewcontroller,我想让用户通过按“i”按钮获得更多关于二维码的信息。依次调用“settingTapped”,但是由于某种原因它不起作用
标签: iphone xcode ios presentmodalviewcontroller