react-native -v
:0.55.0 npm ls rnpm-plugin-windows
:0.2.8 npm ls react-native-windows
:0.55.0-rc.0 node -v
:8.11.3 npm -v
:5.6.0 yarn --version
:1.7.0
目标平台:UWP
RadaeeManager.cs
class RadaeeManager : SimpleViewManager<MainPage>
{
public MainPage _mainPage;
public override string Name
{
get
{
return "RCTRadaeeView";
}
}
public RadaeeManager()
{
_mainPage = new MainPage();
}
protected override MainPage CreateViewInstance(ThemedReactContext reactContext)
{
return _mainPage;
}
}
MainPage.xaml.cs
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
}
async private void BrowsFile(Object sender, RoutedEventArgs e)
{
FileOpenPicker filePicker;
filePicker = new FileOpenPicker();
filePicker.ViewMode = PickerViewMode.List;
filePicker.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
filePicker.FileTypeFilter.Add(".PDF");
filePicker.FileTypeFilter.Add(".pdf");
StorageFile file = await filePicker.PickSingleFileAsync();
if (file != null)
{
IRandomAccessStream stream = await file.OpenAsync(FileAccessMode.ReadWrite);
if (stream != null)
{
Frame rootFrame = Window.Current.Content as Frame;
rootFrame.Navigate(typeof(PDFReaderPage), stream);
}
}
}
}
PDFReaderPage.xaml.cs
public sealed partial class PDFReaderPage : Page, PDFView.PDFViewListener
{
IRandomAccessStream m_stream;
public PDFReaderPage()
{
this.InitializeComponent();
Windows.UI.Core.CoreWindow rcWindow = Window.Current.CoreWindow;
Rect rcScreen = rcWindow.Bounds;
mPDFView.Width = rcScreen.Width;
mPDFView.Height = rcScreen.Height;
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
m_stream = (IRandomAccessStream)e.Parameter;
m_doc = new PDFDoc();
PDF_ERROR err = m_doc.Open(m_stream, "");
switch (err)
{
case PDF_ERROR.err_ok:
m_view = new PDFViewVert(mPDFView);
m_view.vOpen(m_doc, 4, 0xFFCCCCCC, this);
initOptionPanels();
break;
case PDF_ERROR.err_password:
break;
default:
break;
}
}
}
使用此代码,我无法返回到我的react应用程序。 但是,如果我不使用Frame.Navigate,我可以返回,但是与pdf的交互已中断。见下文 RadaeeManager.cs
class RadaeeManager : SimpleViewManager<PDFReaderPage>
{
public PDFReaderPage _mainPage;
public override string Name
{
get
{
return "RCTRadaeeView";
}
}
public RadaeeManager()
{
_mainPage = new PDFReaderPage();
}
protected override PDFReaderPage CreateViewInstance(ThemedReactContext reactContext)
{
return _mainPage;
}
}
PDFReaderPage.xaml.cs
public sealed partial class PDFReaderPage : Page, PDFView.PDFViewListener
{
IRandomAccessStream m_stream;
public PDFReaderPage()
{
this.InitializeComponent();
Windows.UI.Core.CoreWindow rcWindow = Window.Current.CoreWindow;
Rect rcScreen = rcWindow.Bounds;
mPDFView.Width = rcScreen.Width;
mPDFView.Height = rcScreen.Height;
openFile();
}
protected override void openFile(NavigationEventArgs e)
{
ApplicationData data = ApplicationData.Current;
StorageFile file = await data.LocalCacheFolder.GetFileAsync("pdf.pdf");
m_stream = await file.OpenAsync(FileAccessMode.ReadWrite); m_doc = new PDFDoc();
m_stream = (IRandomAccessStream)e.Parameter;
m_doc = new PDFDoc();
PDF_ERROR err = m_doc.Open(m_stream, "");
switch (err)
{
case PDF_ERROR.err_ok:
m_view = new PDFViewVert(mPDFView);
m_view.vOpen(m_doc, 4, 0xFFCCCCCC, this);
initOptionPanels();
break;
case PDF_ERROR.err_password:
break;
default:
break;
}
}
}
这是我可以使Radaee发挥出色但无法返回到我的应用的方法。
我需要打开本机视图来编辑pdf,然后需要返回到我的应用程序
如果我使用Frame.Navigate打开radaee页面,则无法返回我的react应用。 但是,如果我打开radaee页面并返回简单信息,则无法正确使用该插件。
感谢您的帮助!