2014-04-14 29 views
0

我正在iOS應用程序中使用Moodstocks sdk。我想要發生以下情況:如何獲取心情股票掃描導致在textview?

  1. 當用戶掃描該項目時,它將打開一個包含該項目信息的特定文本視圖。

我該怎麼做呢?非常感謝您的幫助!

+0

它必須是一個文本視圖,或者你只是想顯示結果信息? – james075

+0

,你是什麼意思的'有關該項目'的信息?你只是在談論圖片的名字嗎? – james075

+0

我想顯示一本書的引文。就像這樣:艾薩克森,沃爾特。史蒂夫喬布斯紐約:Simon&Schuster,2011.打印。 – user2516876

回答

3

我假設你已經收錄你的形象和實施MSScanner + MSAutoScannerSession簡而言之,開始了與Moodstocks SDK。否則,請告訴我,我會向您解釋,或者您可以按照本教程進行操作:Getting started with Moodstocks SDK in few steps

我會通過顯示ActionSheet來解決您的問題,如果您只想顯示識別圖像identifier,這會更有意義。

對一個結果,didFindResult:委託方法被調用,您可以訪問它包含了識別的圖像信息的MSResult對象:

// set UIActionSheetDelegate protocol 

@interface ViewController() <MSAutoScannerSessionDelegate, UIActionSheetDelegate> 

//... 

- (void)session:(id)scannerSession didFindResult:(MSResult *)result 
{ 
    // check if result exist 
    if (result) { 

     // result.string contains your image identifier 
     // (e.g "steve jobs" if you have named your image "steve jobs.png") 
     NSString *citation; 

     if ([[result string] isEqualToString:@"Steve Jobs"]) { 
      citation = @"Your time is limited, so don't waste it living someone else's life." 
         "Don't be trapped by dogma - which is living with the results of other people's thinking." 
         "Don't let the noise of others' opinions drown out your own inner voice." 
         "And most important, have the courage to follow your heart and intuition."; 
     } 
     else { 
      // other checks ..... 
     } 

     // display an action sheet with the result string 
     dispatch_async(dispatch_get_main_queue(), ^{ 

      UIActionSheet *asView = [[UIActionSheet alloc] initWithTitle:citation 
                   delegate:self 
                 cancelButtonTitle:@"OK" 
                destructiveButtonTitle:nil 
                 otherButtonTitles:nil]; 
      [asView showInView:self.view]; 
     }); 
    } 
} 

實現UIAlertViewDelegate方法:

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex; 
{ 
    // handle actions if needed and 
    // do not forget to resume the scanner session 

    [_scannerSession resumeProcessing]; 
} 

當然,MSResult不僅包含字符串標識符,還可以檢索更多的屬性。 see the doc