iOS Question i can not Open local files with external apps

shugeyi

Member
Licensed User
Longtime User
i find the example here: https://www.b4x.com/android/forum/threads/open-local-files-with-external-apps.51941/#content

my code is here:
Sub Process_Globals
Private m_PageReport As Page
Public g_DI As DocumentInteraction
End Sub

Private Sub Application_Start (Nav As NavigationController)
m_PageReport.Initialize("PageReport")
m_PageReport.Title = "首页"
m_PageReport.RootPanel.Color = g_colorBack
NavControl.ShowPage(m_PageReport)
g_DI.Initialize("di",File.DirDocuments,"111.doc")
g_DI.UTI="com.microsoft.word.doc"
End Sub

Sub PageReport_Click
If g_DI.OpenFile(m_PageReport.RootPanel)=False Then
Log("openwordfileerror")
End If
End Sub

i install my app and word app on my ipad mini and
then i run the app, the 111.doc can not open and the openfile function return true
the screen show the blank page ,and no error happened
why?
can somebody help me? thanks
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
Please use [code]code here...[/code] tags when posting code.

Are you sure that the sub is executed? Change your code to:

B4X:
Sub PageReport_Click
   Log(g_DI.OpenFile(m_PageReport.RootPanel))
End Sub

If it is called and it is not opened then try to pass a BarButton:
B4X:
Private Sub Application_Start (Nav As NavigationController)
   m_PageReport.Initialize("PageReport")
   m_PageReport.Title = "首页"
   m_PageReport.RootPanel.Color = Colors.White
   Nav.ShowPage(m_PageReport)
   g_DI.Initialize("di",File.DirDocuments,"111.doc")
   g_DI.UTI="com.microsoft.word.doc"
   Dim bb As BarButton
   bb.InitializeText("open", "open")
   m_PageReport.TopRightButtons = Array (bb)
End Sub

Sub PageReport_Click
   Log(g_DI.OpenFile(m_PageReport.TopRightButtons.Get(0)))
End Sub
 
Upvote 0

shugeyi

Member
Licensed User
Longtime User
i use your code then it works ,thanks
when i click the page ,then a menu show on the TopRightbutton,
i click "copy to word" , then the doc opened
but can i open the doc without click the menu?
 
Upvote 0
Top