2012-11-18 10 views
0

我還是新手,在iPhone上進行編程,並研究過我的問題,但沒有任何解決方案的運氣。zbar didFinishPickingMediaWithInfo在標籤內更改視圖(情節提要)

我設法按照ZBar SDK Integration tutorial有一個工作的應用程序在最後,在標籤控制器內。

我想要做的是,將結果移動到一個單獨的ViewController。

- (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; 

    ProductViewController *product = [self.storyboard instantiateViewControllerWithIdentifier: @"ProductView"]; 

    product.resultImage = [info objectForKey: UIImagePickerControllerOriginalImage]; 
    product.resultText = symbol.data; 

    [reader dismissModalViewControllerAnimated:YES]; 
    [self presentModalViewController:product animated:YES]; 
} 

我與代碼的問題是產品視圖控制器從不顯示。

使用Xcode 4.5,iOS 6 SDK。

回答

0

我最終放棄了上述方法,而是我navigigation控制器來處理顯示的附加功能。

顯示掃描:

[[self targetController] displayNewObject:scan];

在接收端:

- (void)displayNewObject:(_Scan *)scan 
{ 
    self.scan = scan; 
    self.tabBarController.selectedViewController = [self.tabBarController.viewControllers objectAtIndex:1]; 
    [[self navigationController] popToRootViewControllerAnimated:NO]; 
    [self performSegueWithIdentifier: @"ShowScanDetail" sender: self]; 
    self.scan = nil; 
} 
+0

如果有人在更多的細節後,我可以發佈更多 –

1

,您是否試圖

UIViewController *newTopViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"ProductView"]; 
[reader presentViewController:newTopViewController animated:YES completion:nil]; 
+0

我沒有回答我的問題,所以我不得不重寫我的問題到的東西更容易管理。 我已經更新了我的問題與解決方案我想出 –