2014-04-01 65 views
2

有沒有人有一個想法,這是一個FileOpener2插件爲Phonegap/cordova應用程序中的文件的正確路徑?特別是在iOS版本 我已經嘗試了這一點:如果我創建一個<img src="examplePicture.jpg">標籤fileOpener2中的正確文件路徑iOS的Phonegap/cordova插件

cordova.plugins.fileOpener2.open(
    'examplePicture.jpg', 
    'image/jpeg', 
    { 
     error : function(errorObj) { 
      alert('Error status: ' + errorObj.status + ' - Error message: ' + errorObj.message); 
     }, 
     success : function() { 
      alert('file opened successfully'); 
     } 
    } 
); 

,畫面會正確顯示。 Safari瀏覽器調試器告訴我,資源沒有被發現,如果我嘗試測試,在iPhone模擬器與此錯誤的應用程序崩潰:

2014-04-01 10:23:31.766 MobileApp[1162:70b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UIDocumentInteractionController: invalid scheme (null). Only the file scheme is supported.' 
*** First throw call stack: 
(
    0 CoreFoundation      0x000e95e4 __exceptionPreprocess + 180 
    1 libobjc.A.dylib      0x01c628b6 objc_exception_throw + 44 
    2 CoreFoundation      0x000e9448 +[NSException raise:format:arguments:] + 136 
    3 Foundation       0x01842fee -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 116 
    4 UIKit        0x007e5a7e -[UIDocumentInteractionController setURL:] + 201 
    5 UIKit        0x007e524f -[UIDocumentInteractionController initWithURL:] + 77 
    6 UIKit        0x007e51ea +[UIDocumentInteractionController interactionControllerWithURL:] + 59 
    7 MobileApp       0x00030da5 __20-[FileOpener2 open:]_block_invoke_2 + 69 
    8 libdispatch.dylib     0x021b67f8 _dispatch_call_block_and_release + 15 
    9 libdispatch.dylib     0x021cb4b0 _dispatch_client_callout + 14 
    10 libdispatch.dylib     0x021b975e _dispatch_main_queue_callback_4CF + 340 
    11 CoreFoundation      0x0014ea5e __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 14 
    12 CoreFoundation      0x0008f6bb __CFRunLoopRun + 1963 
    13 CoreFoundation      0x0008eac3 CFRunLoopRunSpecific + 467 
    14 CoreFoundation      0x0008e8db CFRunLoopRunInMode + 123 
    15 GraphicsServices     0x031049e2 GSEventRunModal + 192 
    16 GraphicsServices     0x03104809 GSEventRun + 104 
    17 UIKit        0x0034fd3b UIApplicationMain + 1225 
    18 MobileApp       0x00023bbc main + 92 
    19 MobileApp       0x00023b4d start + 53 
) 
libc++abi.dylib: terminating with uncaught exception of type NSException 
(lldb) 

有也這個插件可以打開附件(圖片替代,Excel表格,Word文檔)?

編輯: 的fileOpener2對象是在應用程序也可用,所以該插件似乎被正確安裝

+0

找出任何東西.. ?? – shashwat

+0

尚未,對不起:( – oneandonlycore

+1

插件的phonegap文檔真的很爛:'( – shashwat

回答

2

試圖改變插件的IOS源(插件/ FileOpener2.m)線

fileURL = [NSURL URLWithString:path]; 

fileURL = [NSURL fileURLWithPath:path]; 

對於科爾多瓦3.4.0(及以上):如果你從文件系統inste條目'examplePicture.jpg'的廣告使用entry.toNativeURL()作爲第一個參數。

+0

,幫助謝謝...現在應用程序列表出現,但我仍然有一個錯誤:無法獲取網址數據:該操作無法完成。(Cocoa錯誤260.)我會盡快進行測試。 – oneandonlycore