如何解决如何防止从“在我的iPhone”文件夹中共享文件
我有一个xamarin表单应用程序,可以将文件下载到“在我的iPhone上”文件夹中。但是,当我在手机上下载文件时,我可以去那里并与其他应用共享。
但是我想防止这种情况。从我的应用下载文件时,我希望该文件不要从“在我的iPhone上”上传到另一台设备。
如何防止这种情况?也许我可以使用mdm来防止这种情况,但是怎么办呢? 有没有一种方法可以通过mdm托管应用程序配置来阻止它。我的一些客户说,我们可以使用mdm中的plist文件来防止这种情况。但是我对mdm的了解很少。如何使用mdm? 我需要针对ios和android的解决方案。但尤其是对于ios。
谢谢。
解决方法
谢谢杰克。
我查看了您的发送线程,并进行了尝试。但这对我没有用。 我创建了从UINavigationItem继承的MyUINavigationItem。而且我重写SetRightBarButtonItem为null。在重写从QLPreviewController继承的PdfPreviewController上的UINavigationItem之后。然后将NavigationItem设置为MyUINavigationItem对象。但这对我不起作用。我的代码如下:
public class DocumentView : IDocumentView
{
void IDocumentView.DocumentView(string file,string title)
{
PdfPreviewController previewController = new PdfPreviewController();
if (File.Exists(file))
{
previewController.NavigationItem.SetRightBarButtonItem(null,false); //I tried this line as both comment and not comment but it didn't work
previewController.NavigationItem.SetRightBarButtonItems(null,false); //I tried this line as both comment and not comment but it didn't work
previewController.DataSource = new PDFPreviewControllerDataSource(NSUrl.FromFilename(file),title);
UIApplication.SharedApplication.KeyWindow.RootViewController.PresentViewController(previewController,true,null);
}
}
}
public class PdfPreviewController : QLPreviewController
{
MyUINavigationItem item = new MyUINavigationItem();
public override UINavigationItem NavigationItem => item;
}
public class MyUINavigationItem : UINavigationItem
{
public MyUINavigationItem()
{
}
public override void SetRightBarButtonItem(UIBarButtonItem item,bool animated)
{
//base.SetRightBarButtonItem(item,animated); //I tried this line as comment but it didn't work or
//base.SetRightBarButtonItem(null,animated); //I tried this line but it didn't work
}
public override void SetRightBarButtonItems(UIBarButtonItem[] items,bool animated)
{
//base.SetRightBarButtonItems(items,animated); //I tried this line as comment but it didn't work or
//base.SetRightBarButtonItems(null,animated); //I tried this line but it throwed exception
//base.SetRightBarButtonItems(new UIBarButtonItem[0],animated); //I tried this line but it didn't work
}
}
但是在您提出建议后,我寻找了启用或隐藏共享按钮。而且我可以访问UINavigationController的子视图控制器,并将RightBarButtonItem启用值设置为false。
public class PdfPreviewController : QLPreviewController
{
public override void ViewDidAppear(bool animated)
{
try
{
ActionMenuControl();
}
catch (Exception ex)
{
}
}
public override void ViewDidLayoutSubviews()
{
try
{
ActionMenuControl();
}
catch (Exception ex)
{
}
}
public void ActionMenuControl()
{
try
{
if (this.ChildViewControllers.Length != 0)
{
var navigationController = this.ChildViewControllers.First() as UINavigationController;
if (navigationController.View.Subviews.Length != 0)
{
var layoutContainerView = navigationController.View.Subviews.FirstOrDefault(x => x is UINavigationBar) as UINavigationBar;
if (layoutContainerView != null)
{
if (layoutContainerView.Items.Length != 0)
{
var item = layoutContainerView.Items[0];
if (item.RightBarButtonItems.Length != 0)
item.RightBarButtonItem.Enabled = false;
}
}
}
var toolbar = navigationController.Toolbar;
if (toolbar != null)
{
if(toolbar.Items.Length != 0)
{
toolbar.Items[0].Enabled = false;
}
}
}
}
catch (Exception ex)
{
}
}
}
它适用于右栏。但是,如果打开mp3文件,“共享”按钮将出现在工具栏上(底部),但我没有访问它。我该如何处理mp3文件?如何访问工具栏? (实际上,当打开并移动它时不起作用。但是,如果我将其打开并移动,它就可以工作了(因为它进入了ViewDidLayoutSubviews事件))
很抱歉,请长时间回复。但是我想告诉我我做了什么。因为也许我确实错过了一些东西。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。