[DocPicker]Adding Doc Picker Sample
|
@ -0,0 +1,32 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2012
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocPicker", "DocPicker\DocPicker.csproj", "{3E6D59C1-E184-4228-86B3-05907460DFA4}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|iPhoneSimulator = Debug|iPhoneSimulator
|
||||
Release|iPhoneSimulator = Release|iPhoneSimulator
|
||||
Debug|iPhone = Debug|iPhone
|
||||
Release|iPhone = Release|iPhone
|
||||
Ad-Hoc|iPhone = Ad-Hoc|iPhone
|
||||
AppStore|iPhone = AppStore|iPhone
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{3E6D59C1-E184-4228-86B3-05907460DFA4}.Ad-Hoc|iPhone.ActiveCfg = Ad-Hoc|iPhone
|
||||
{3E6D59C1-E184-4228-86B3-05907460DFA4}.Ad-Hoc|iPhone.Build.0 = Ad-Hoc|iPhone
|
||||
{3E6D59C1-E184-4228-86B3-05907460DFA4}.AppStore|iPhone.ActiveCfg = AppStore|iPhone
|
||||
{3E6D59C1-E184-4228-86B3-05907460DFA4}.AppStore|iPhone.Build.0 = AppStore|iPhone
|
||||
{3E6D59C1-E184-4228-86B3-05907460DFA4}.Debug|iPhone.ActiveCfg = Debug|iPhone
|
||||
{3E6D59C1-E184-4228-86B3-05907460DFA4}.Debug|iPhone.Build.0 = Debug|iPhone
|
||||
{3E6D59C1-E184-4228-86B3-05907460DFA4}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
|
||||
{3E6D59C1-E184-4228-86B3-05907460DFA4}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
|
||||
{3E6D59C1-E184-4228-86B3-05907460DFA4}.Release|iPhone.ActiveCfg = Release|iPhone
|
||||
{3E6D59C1-E184-4228-86B3-05907460DFA4}.Release|iPhone.Build.0 = Release|iPhone
|
||||
{3E6D59C1-E184-4228-86B3-05907460DFA4}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
|
||||
{3E6D59C1-E184-4228-86B3-05907460DFA4}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
|
||||
EndGlobalSection
|
||||
GlobalSection(MonoDevelopProperties) = preSolution
|
||||
StartupItem = DocPicker\DocPicker.csproj
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,340 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using Foundation;
|
||||
using UIKit;
|
||||
using ObjCRuntime;
|
||||
using System.IO;
|
||||
|
||||
namespace DocPicker
|
||||
{
|
||||
// The UIApplicationDelegate for the application. This class is responsible for launching the
|
||||
// User Interface of the application, as well as listening (and optionally responding) to
|
||||
// application events from iOS.
|
||||
[Register ("AppDelegate")]
|
||||
public partial class AppDelegate : UIApplicationDelegate
|
||||
{
|
||||
#region Static Properties
|
||||
public const string TestFilename = "test.txt";
|
||||
#endregion
|
||||
|
||||
#region Computed Properties
|
||||
public override UIWindow Window { get; set; }
|
||||
public bool HasiCloud { get; set; }
|
||||
public bool CheckingForiCloud { get; set; }
|
||||
public NSUrl iCloudUrl { get; set; }
|
||||
|
||||
public GenericTextDocument Document { get; set; }
|
||||
public NSMetadataQuery Query { get; set; }
|
||||
public NSData Bookmark { get; set; }
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
/// <summary>
|
||||
/// Starts a query to look for the sample Test File.
|
||||
/// </summary>
|
||||
private void FindDocument () {
|
||||
Console.WriteLine ("Finding Document...");
|
||||
|
||||
// Create a new query and set it's scope
|
||||
Query = new NSMetadataQuery();
|
||||
Query.SearchScopes = new NSObject [] {
|
||||
NSMetadataQuery.UbiquitousDocumentsScope,
|
||||
NSMetadataQuery.UbiquitousDataScope,
|
||||
NSMetadataQuery.AccessibleUbiquitousExternalDocumentsScope
|
||||
};
|
||||
|
||||
// Build a predicate to locate the file by name and attach it to the query
|
||||
var pred = NSPredicate.FromFormat ("%K == %@"
|
||||
, new NSObject[] {
|
||||
NSMetadataQuery.ItemFSNameKey
|
||||
, new NSString(TestFilename)});
|
||||
Query.Predicate = pred;
|
||||
|
||||
// Register a notification for when the query returns
|
||||
NSNotificationCenter.DefaultCenter.AddObserver (this
|
||||
, new Selector("queryDidFinishGathering:")
|
||||
, NSMetadataQuery.DidFinishGatheringNotification
|
||||
, Query);
|
||||
|
||||
// Start looking for the file
|
||||
Query.StartQuery ();
|
||||
Console.WriteLine ("Querying: {0}", Query.IsGathering);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Callback for when the query finishs gathering documents.
|
||||
/// </summary>
|
||||
/// <param name="notification">Notification.</param>
|
||||
[Export("queryDidFinishGathering:")]
|
||||
public void DidFinishGathering (NSNotification notification) {
|
||||
Console.WriteLine ("Finish Gathering Documents.");
|
||||
|
||||
// Access the query and stop it from running
|
||||
var query = (NSMetadataQuery)notification.Object;
|
||||
query.DisableUpdates();
|
||||
query.StopQuery();
|
||||
|
||||
// Release the notification
|
||||
NSNotificationCenter.DefaultCenter.RemoveObserver (this
|
||||
, NSMetadataQuery.DidFinishGatheringNotification
|
||||
, query);
|
||||
|
||||
// Load the document that the query returned
|
||||
LoadDocument(query);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Loads the document.
|
||||
/// </summary>
|
||||
/// <param name="query">Query.</param>
|
||||
private void LoadDocument (NSMetadataQuery query) {
|
||||
Console.WriteLine ("Loading Document...");
|
||||
|
||||
// Take action based on the returned record count
|
||||
switch (query.ResultCount) {
|
||||
case 0:
|
||||
// Create a new document
|
||||
CreateNewDocument ();
|
||||
break;
|
||||
case 1:
|
||||
// Gain access to the url and create a new document from
|
||||
// that instance
|
||||
NSMetadataItem item = (NSMetadataItem)query.ResultAtIndex (0);
|
||||
var url = (NSUrl)item.ValueForAttribute (NSMetadataQuery.ItemURLKey);
|
||||
|
||||
// Load the document
|
||||
OpenDocument (url);
|
||||
break;
|
||||
default:
|
||||
// There has been an issue
|
||||
Console.WriteLine ("Issue: More than one document found...");
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Public Methods
|
||||
/// <summary>
|
||||
/// Opens the document.
|
||||
/// </summary>
|
||||
/// <param name="url">URL.</param>
|
||||
public void OpenDocument(NSUrl url) {
|
||||
|
||||
Console.WriteLine ("Attempting to open: {0}", url);
|
||||
Document = new GenericTextDocument (url);
|
||||
|
||||
// Open the document
|
||||
Document.Open ( (success) => {
|
||||
if (success) {
|
||||
Console.WriteLine ("Document Opened");
|
||||
} else
|
||||
Console.WriteLine ("Failed to Open Document");
|
||||
});
|
||||
|
||||
// Inform caller
|
||||
RaiseDocumentLoaded (Document);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates the new document.
|
||||
/// </summary>
|
||||
public void CreateNewDocument() {
|
||||
// Create path to new file
|
||||
// var docsFolder = Environment.GetFolderPath (Environment.SpecialFolder.Personal);
|
||||
var docsFolder = Path.Combine(iCloudUrl.Path, "Documents");
|
||||
var docPath = Path.Combine (docsFolder, TestFilename);
|
||||
var ubiq = new NSUrl (docPath, false);
|
||||
|
||||
// Create new document at path
|
||||
Console.WriteLine ("Creating Document at:" + ubiq.AbsoluteString);
|
||||
Document = new GenericTextDocument (ubiq);
|
||||
|
||||
// Set the default value
|
||||
Document.Contents = "(default value)";
|
||||
|
||||
// Save document to path
|
||||
Document.Save (Document.FileUrl, UIDocumentSaveOperation.ForCreating, (saveSuccess) => {
|
||||
Console.WriteLine ("Save completion:" + saveSuccess);
|
||||
if (saveSuccess) {
|
||||
Console.WriteLine ("Document Saved");
|
||||
} else {
|
||||
Console.WriteLine ("Unable to Save Document");
|
||||
}
|
||||
});
|
||||
|
||||
// Inform caller
|
||||
RaiseDocumentLoaded (Document);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves the document.
|
||||
/// </summary>
|
||||
/// <returns><c>true</c>, if document was saved, <c>false</c> otherwise.</returns>
|
||||
public bool SaveDocument() {
|
||||
bool successful = false;
|
||||
|
||||
// Save document to path
|
||||
Document.Save (Document.FileUrl, UIDocumentSaveOperation.ForOverwriting, (saveSuccess) => {
|
||||
Console.WriteLine ("Save completion: " + saveSuccess);
|
||||
if (saveSuccess) {
|
||||
Console.WriteLine ("Document Saved");
|
||||
successful = true;
|
||||
} else {
|
||||
Console.WriteLine ("Unable to Save Document");
|
||||
successful=false;
|
||||
}
|
||||
});
|
||||
|
||||
// Return results
|
||||
return successful;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Override Methods
|
||||
/// <summary>
|
||||
/// Finisheds the launching.
|
||||
/// </summary>
|
||||
/// <param name="application">Application.</param>
|
||||
public override void FinishedLaunching (UIApplication application)
|
||||
{
|
||||
|
||||
// Start a new thread to check and see if the user has iCloud
|
||||
// enabled.
|
||||
new Thread(new ThreadStart(() => {
|
||||
// Inform caller that we are checking for iCloud
|
||||
CheckingForiCloud = true;
|
||||
|
||||
// Checks to see if the user of this device has iCloud
|
||||
// enabled
|
||||
var uburl = NSFileManager.DefaultManager.GetUrlForUbiquityContainer(null);
|
||||
|
||||
// Connected to iCloud?
|
||||
if (uburl == null)
|
||||
{
|
||||
// No, inform caller
|
||||
HasiCloud = false;
|
||||
iCloudUrl =null;
|
||||
Console.WriteLine("Unable to connect to iCloud");
|
||||
InvokeOnMainThread(()=>{
|
||||
var okAlertController = UIAlertController.Create ("iCloud Not Available", "Developer, please check your Entitlements.plist, Bundle ID and Provisioning Profiles.", UIAlertControllerStyle.Alert);
|
||||
okAlertController.AddAction (UIAlertAction.Create ("Ok", UIAlertActionStyle.Default, null));
|
||||
Window.RootViewController.PresentViewController (okAlertController, true, null);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
// Yes, inform caller and save location the the Application Container
|
||||
HasiCloud = true;
|
||||
iCloudUrl = uburl;
|
||||
Console.WriteLine("Connected to iCloud");
|
||||
|
||||
// If we have made the connection with iCloud, start looking for documents
|
||||
InvokeOnMainThread(()=>{
|
||||
// Search for the default document
|
||||
FindDocument ();
|
||||
});
|
||||
}
|
||||
|
||||
// Inform caller that we are no longer looking for iCloud
|
||||
CheckingForiCloud = false;
|
||||
|
||||
})).Start();
|
||||
|
||||
}
|
||||
|
||||
// This method is invoked when the application is about to move from active to inactive state.
|
||||
// OpenGL applications should use this method to pause.
|
||||
public override void OnResignActivation (UIApplication application)
|
||||
{
|
||||
}
|
||||
|
||||
// This method should be used to release shared resources and it should store the application state.
|
||||
// If your application supports background exection this method is called instead of WillTerminate
|
||||
// when the user quits.
|
||||
public override void DidEnterBackground (UIApplication application)
|
||||
{
|
||||
// Trap all errors
|
||||
try {
|
||||
// Values to include in the bookmark packet
|
||||
var resources = new string[] {
|
||||
NSUrl.FileSecurityKey,
|
||||
NSUrl.ContentModificationDateKey,
|
||||
NSUrl.FileResourceIdentifierKey,
|
||||
NSUrl.FileResourceTypeKey,
|
||||
NSUrl.LocalizedNameKey
|
||||
};
|
||||
|
||||
// Create the bookmark
|
||||
NSError err;
|
||||
Bookmark = Document.FileUrl.CreateBookmarkData (NSUrlBookmarkCreationOptions.WithSecurityScope, resources, iCloudUrl, out err);
|
||||
|
||||
// Was there an error?
|
||||
if (err != null) {
|
||||
// Yes, report it
|
||||
Console.WriteLine ("Error Creating Bookmark: {0}", err.LocalizedDescription);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
// Report error
|
||||
Console.WriteLine ("Error: {0}", e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
// This method is called as part of the transiton from background to active state.
|
||||
public override void WillEnterForeground (UIApplication application)
|
||||
{
|
||||
// Is there any bookmark data?
|
||||
if (Bookmark != null) {
|
||||
// Trap all errors
|
||||
try {
|
||||
// Yes, attempt to restore it
|
||||
bool isBookmarkStale;
|
||||
NSError err;
|
||||
var srcUrl = new NSUrl (Bookmark, NSUrlBookmarkResolutionOptions.WithSecurityScope, iCloudUrl, out isBookmarkStale, out err);
|
||||
|
||||
// Was there an error?
|
||||
if (err != null) {
|
||||
// Yes, report it
|
||||
Console.WriteLine ("Error Loading Bookmark: {0}", err.LocalizedDescription);
|
||||
} else {
|
||||
// Load document from bookmark
|
||||
OpenDocument (srcUrl);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
// Report error
|
||||
Console.WriteLine ("Error: {0}", e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// This method is called when the application is about to terminate. Save data, if needed.
|
||||
public override void WillTerminate (UIApplication application)
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
/// <summary>
|
||||
/// Document loaded delegate.
|
||||
/// </summary>
|
||||
public delegate void DocumentLoadedDelegate(GenericTextDocument document);
|
||||
public event DocumentLoadedDelegate DocumentLoaded;
|
||||
|
||||
/// <summary>
|
||||
/// Raises the document loaded event.
|
||||
/// </summary>
|
||||
/// <param name="document">Document.</param>
|
||||
internal void RaiseDocumentLoaded(GenericTextDocument document) {
|
||||
// Inform caller
|
||||
if (this.DocumentLoaded != null) {
|
||||
this.DocumentLoaded (document);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,113 @@
|
|||
using System;
|
||||
using Foundation;
|
||||
using UIKit;
|
||||
|
||||
namespace DocPicker
|
||||
{
|
||||
/// <summary>
|
||||
/// The file representation is a simple text file with .txt extension.
|
||||
/// </summary>
|
||||
public class GenericTextDocument : UIDocument
|
||||
{
|
||||
#region Private Variable Storage
|
||||
private NSString _dataModel;
|
||||
#endregion
|
||||
|
||||
#region Computed Properties
|
||||
/// <summary>
|
||||
/// Gets or sets the contents of the document
|
||||
/// </summary>
|
||||
/// <value>The document contents.</value>
|
||||
public string Contents {
|
||||
get { return _dataModel.ToString (); }
|
||||
set { _dataModel = new NSString(value); }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DocPicker.GenericTextDocument"/> class.
|
||||
/// </summary>
|
||||
public GenericTextDocument (NSUrl url) : base (url)
|
||||
{
|
||||
// Set the default document text
|
||||
this.Contents = "";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="DocPicker.GenericTextDocument"/> class.
|
||||
/// </summary>
|
||||
/// <param name="contents">Contents.</param>
|
||||
public GenericTextDocument (NSUrl url, string contents) : base (url)
|
||||
{
|
||||
// Set the default document text
|
||||
this.Contents = contents;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Override Methods
|
||||
/// <Docs>To be added.</Docs>
|
||||
/// <param name="outError">To be added.</param>
|
||||
/// <returns>To be added.</returns>
|
||||
/// <para>(More documentation for this node is coming)</para>
|
||||
/// <summary>
|
||||
/// Loads from contents.
|
||||
/// </summary>
|
||||
/// <param name="contents">Contents.</param>
|
||||
/// <param name="typeName">Type name.</param>
|
||||
public override bool LoadFromContents (NSObject contents, string typeName, out NSError outError)
|
||||
{
|
||||
// Clear the error state
|
||||
outError = null;
|
||||
|
||||
// Were any contents passed to the document?
|
||||
if (contents != null) {
|
||||
_dataModel = NSString.FromData( (NSData)contents, NSStringEncoding.UTF8 );
|
||||
}
|
||||
|
||||
// Inform caller that the document has been modified
|
||||
RaiseDocumentModified (this);
|
||||
|
||||
// Return success
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <Docs>To be added.</Docs>
|
||||
/// <summary>
|
||||
/// Application developers should override this method to return the document data to be saved.
|
||||
/// </summary>
|
||||
/// <remarks>(More documentation for this node is coming)</remarks>
|
||||
/// <returns>The for type.</returns>
|
||||
/// <param name="typeName">Type name.</param>
|
||||
/// <param name="outError">Out error.</param>
|
||||
public override NSObject ContentsForType (string typeName, out NSError outError)
|
||||
{
|
||||
// Clear the error state
|
||||
outError = null;
|
||||
|
||||
// Convert the contents to a NSData object and return it
|
||||
NSData docData = _dataModel.Encode(NSStringEncoding.UTF8);
|
||||
return docData;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Events
|
||||
/// <summary>
|
||||
/// Document modified delegate.
|
||||
/// </summary>
|
||||
public delegate void DocumentModifiedDelegate(GenericTextDocument document);
|
||||
public event DocumentModifiedDelegate DocumentModified;
|
||||
|
||||
/// <summary>
|
||||
/// Raises the document modified event.
|
||||
/// </summary>
|
||||
internal void RaiseDocumentModified(GenericTextDocument document) {
|
||||
// Inform caller
|
||||
if (this.DocumentModified != null) {
|
||||
this.DocumentModified (document);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,152 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">iPhoneSimulator</Platform>
|
||||
<ProjectTypeGuids>{FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<ProjectGuid>{3E6D59C1-E184-4228-86B3-05907460DFA4}</ProjectGuid>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>DocPicker</RootNamespace>
|
||||
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
|
||||
<AssemblyName>DocPicker</AssemblyName>
|
||||
<Description>A simple application that shows how to use the Document Picker to
|
||||
access external, cloud-based Documents.</Description>
|
||||
<TargetFrameworkIdentifier>Xamarin.iOS</TargetFrameworkIdentifier>
|
||||
<TargetFrameworkVersion>v1.0</TargetFrameworkVersion>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhoneSimulator' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\iPhoneSimulator\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<MtouchLink>None</MtouchLink>
|
||||
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
|
||||
<MtouchDebug>true</MtouchDebug>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\iPhoneSimulator\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<MtouchLink>None</MtouchLink>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|iPhone' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\iPhone\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
|
||||
<MtouchDebug>true</MtouchDebug>
|
||||
<CodesignKey>iPhone Developer: Amy Burns (6VJF5AQF8M)</CodesignKey>
|
||||
<IpaPackageName>
|
||||
</IpaPackageName>
|
||||
<MtouchI18n>
|
||||
</MtouchI18n>
|
||||
<MtouchArch>ARMv7</MtouchArch>
|
||||
<MtouchUseRefCounting>true</MtouchUseRefCounting>
|
||||
<CodesignProvision>05c6fe6e-7566-455c-8284-2665a7ea071f</CodesignProvision>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\iPhone\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<CodesignKey>iPhone Developer</CodesignKey>
|
||||
<MtouchArch>ARMv7, ARM64</MtouchArch>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Ad-Hoc|iPhone' ">
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\iPhone\Ad-Hoc</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
|
||||
<BuildIpa>true</BuildIpa>
|
||||
<CodesignProvision>Automatic:AdHoc</CodesignProvision>
|
||||
<CodesignKey>iPhone Distribution</CodesignKey>
|
||||
<MtouchArch>ARMv7, ARM64</MtouchArch>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'AppStore|iPhone' ">
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\iPhone\AppStore</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodesignKey>iPhone Distribution</CodesignKey>
|
||||
<CodesignEntitlements>Entitlements.plist</CodesignEntitlements>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<CodesignProvision>Automatic:AppStore</CodesignProvision>
|
||||
<MtouchArch>ARMv7, ARM64</MtouchArch>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="Xamarin.iOS" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BundleResource Include="Resources\Default-568h%402x.png" />
|
||||
<BundleResource Include="Resources\Default-Landscape%402x~ipad.png" />
|
||||
<BundleResource Include="Resources\Default-Landscape~ipad.png" />
|
||||
<BundleResource Include="Resources\Default-Portrait%402x~ipad.png" />
|
||||
<BundleResource Include="Resources\Default-Portrait~ipad.png" />
|
||||
<BundleResource Include="Resources\Default.png" />
|
||||
<BundleResource Include="Resources\Default%402x.png" />
|
||||
<BundleResource Include="Resources\Icon-60.png" />
|
||||
<BundleResource Include="Resources\Icon-60%402x.png" />
|
||||
<BundleResource Include="Resources\Icon-72.png" />
|
||||
<BundleResource Include="Resources\Icon-72%402x.png" />
|
||||
<BundleResource Include="Resources\Icon-76.png" />
|
||||
<BundleResource Include="Resources\Icon-76%402x.png" />
|
||||
<BundleResource Include="Resources\Icon-Small-50.png" />
|
||||
<BundleResource Include="Resources\Icon-Small-50%402x.png" />
|
||||
<BundleResource Include="Resources\Icon-Small.png" />
|
||||
<BundleResource Include="Resources\Icon-Small%402x.png" />
|
||||
<BundleResource Include="Resources\Icon-Spotlight-40.png" />
|
||||
<BundleResource Include="Resources\Icon-Spotlight-40%402x.png" />
|
||||
<BundleResource Include="Resources\Icon.png" />
|
||||
<BundleResource Include="Resources\Icon%402x.png" />
|
||||
<BundleResource Include="Resources\Logo.png" />
|
||||
<BundleResource Include="Resources\Logo%402x.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Info.plist" />
|
||||
<None Include="Entitlements.plist" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Main.cs" />
|
||||
<Compile Include="AppDelegate.cs" />
|
||||
<Compile Include="DocPickerViewController.cs" />
|
||||
<Compile Include="DocPickerViewController.designer.cs">
|
||||
<DependentUpon>DocPickerViewController.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Classes\GenericTextDocument.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<InterfaceDefinition Include="MainStoryboard_iPhone.storyboard" />
|
||||
<InterfaceDefinition Include="MainStoryboard_iPad.storyboard" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ITunesArtwork Include="Resources\iTunesArtwork.png" />
|
||||
<ITunesArtwork Include="Resources\iTunesArtwork%402x.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Classes\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
|
||||
</Project>
|
|
@ -0,0 +1,254 @@
|
|||
using System;
|
||||
using CoreGraphics;
|
||||
|
||||
using Foundation;
|
||||
using UIKit;
|
||||
using MobileCoreServices;
|
||||
|
||||
namespace DocPicker
|
||||
{
|
||||
public partial class DocPickerViewController : UIViewController
|
||||
{
|
||||
#region Private Variables
|
||||
private nfloat _documentTextHeight = 0;
|
||||
#endregion
|
||||
|
||||
#region Computed Properties
|
||||
static bool UserInterfaceIdiomIsPhone {
|
||||
get { return UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the delegate of the current running application
|
||||
/// </summary>
|
||||
/// <value>The this app.</value>
|
||||
public AppDelegate ThisApp {
|
||||
get { return (AppDelegate)UIApplication.SharedApplication.Delegate; }
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
public DocPickerViewController (IntPtr handle) : base (handle)
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
/// <summary>
|
||||
/// Moves a file from a given source url location to a given destination url.
|
||||
/// </summary>
|
||||
/// <returns><c>true</c>, if file was moved, <c>false</c> otherwise.</returns>
|
||||
/// <param name="fromURL">From UR.</param>
|
||||
/// <param name="toURL">To UR.</param>
|
||||
private bool MoveFile(string fromURL, string toURL) {
|
||||
bool successful = true;
|
||||
|
||||
// Get source options
|
||||
var srcURL = NSUrl.FromFilename (fromURL);
|
||||
var srcIntent = NSFileAccessIntent.CreateReadingIntent (srcURL, NSFileCoordinatorReadingOptions.ForUploading);
|
||||
|
||||
// Get destination options
|
||||
var dstURL = NSUrl.FromFilename (toURL);
|
||||
var dstIntent = NSFileAccessIntent.CreateReadingIntent (dstURL, NSFileCoordinatorReadingOptions.ForUploading);
|
||||
|
||||
// Create an array
|
||||
var intents = new NSFileAccessIntent[] {
|
||||
srcIntent,
|
||||
dstIntent
|
||||
};
|
||||
|
||||
// Initialize a file coordination with intents
|
||||
var queue = new NSOperationQueue ();
|
||||
var fileCoordinator = new NSFileCoordinator ();
|
||||
fileCoordinator.CoordinateAccess (intents, queue, (err) => {
|
||||
// Was there an error?
|
||||
if (err!=null) {
|
||||
// Yes, inform caller
|
||||
Console.WriteLine("Error: {0}",err.LocalizedDescription);
|
||||
successful = false;
|
||||
}
|
||||
});
|
||||
|
||||
// Return successful
|
||||
return successful;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Methods
|
||||
/// <summary>
|
||||
/// Adjust the size of the <c>DocumentText</c> text editor to account for the keyboard being displayed
|
||||
/// </summary>
|
||||
/// <param name="height">The new text area height</param>
|
||||
private void MoveDocumentText(nfloat height) {
|
||||
|
||||
// Animate size change
|
||||
UIView.BeginAnimations("keyboard");
|
||||
UIView.SetAnimationDuration(0.3f);
|
||||
|
||||
// Adjust frame to move the text away from the keyboard
|
||||
DocumentText.Frame = new CGRect (0, DocumentText.Frame.Y, DocumentText.Frame.Width, height);
|
||||
|
||||
// Start animation
|
||||
UIView.CommitAnimations();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Override Methods
|
||||
/// <Docs>Called when the system is running low on memory.</Docs>
|
||||
/// <summary>
|
||||
/// Dids the receive memory warning.
|
||||
/// </summary>
|
||||
public override void DidReceiveMemoryWarning ()
|
||||
{
|
||||
// Releases the view if it doesn't have a superview.
|
||||
base.DidReceiveMemoryWarning ();
|
||||
|
||||
// Release any cached data, images, etc that aren't in use.
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Views the did load.
|
||||
/// </summary>
|
||||
public override void ViewDidLoad ()
|
||||
{
|
||||
base.ViewDidLoad ();
|
||||
|
||||
// Save the default text area height
|
||||
_documentTextHeight = DocumentText.Frame.Height;
|
||||
|
||||
// var picker = new UIDocumentPickerViewController (srcURL, UIDocumentPickerMode.ExportToService);
|
||||
|
||||
// Watch for a new document being created
|
||||
ThisApp.DocumentLoaded += (document) => {
|
||||
// Display the contents of the document
|
||||
DocumentText.Text = document.Contents;
|
||||
|
||||
// Watch for the document being modified by an outside source
|
||||
document.DocumentModified += (doc) => {
|
||||
// Display the updated contents of the document
|
||||
DocumentText.Text = doc.Contents;
|
||||
Console.WriteLine("Document contents have been updated");
|
||||
};
|
||||
};
|
||||
|
||||
// Wireup events for the text editor
|
||||
DocumentText.ShouldBeginEditing= delegate(UITextView field){
|
||||
//Placeholder
|
||||
MoveDocumentText(_documentTextHeight-170f);
|
||||
return true;
|
||||
};
|
||||
DocumentText.ShouldEndEditing= delegate (UITextView field){
|
||||
MoveDocumentText(_documentTextHeight);
|
||||
ThisApp.Document.Contents = DocumentText.Text;
|
||||
return true;
|
||||
};
|
||||
|
||||
// Wireup the Save button
|
||||
SaveButton.Clicked += (sender, e) => {
|
||||
// Close the keyboard
|
||||
DocumentText.ResignFirstResponder();
|
||||
|
||||
// Save the changes to the document
|
||||
ThisApp.SaveDocument();
|
||||
};
|
||||
|
||||
// Wireup the Action buttom
|
||||
ActionButton.Clicked += (s, e) => {
|
||||
|
||||
// Allow the Document picker to select a range of document types
|
||||
var allowedUTIs = new string[] {
|
||||
UTType.UTF8PlainText,
|
||||
UTType.PlainText,
|
||||
UTType.RTF,
|
||||
UTType.PNG,
|
||||
UTType.Text,
|
||||
UTType.PDF,
|
||||
UTType.Image
|
||||
};
|
||||
|
||||
// Display the picker
|
||||
//var picker = new UIDocumentPickerViewController (allowedUTIs, UIDocumentPickerMode.Open);
|
||||
var pickerMenu = new UIDocumentMenuViewController(allowedUTIs, UIDocumentPickerMode.Open);
|
||||
pickerMenu.DidPickDocumentPicker += (sender, args) => {
|
||||
|
||||
// Wireup Document Picker
|
||||
args.DocumentPicker.DidPickDocument += (sndr, pArgs) => {
|
||||
|
||||
// IMPORTANT! You must lock the security scope before you can
|
||||
// access this file
|
||||
var securityEnabled = pArgs.Url.StartAccessingSecurityScopedResource();
|
||||
|
||||
// Open the document
|
||||
ThisApp.OpenDocument(pArgs.Url);
|
||||
|
||||
// TODO: This should work but doesn't
|
||||
// Apple's WWDC 2014 sample project does this but it blows
|
||||
// up in Xamarin
|
||||
NSFileCoordinator fileCoordinator = new NSFileCoordinator();
|
||||
NSError err;
|
||||
fileCoordinator.CoordinateRead (pArgs.Url, 0, out err, (NSUrl newUrl) => {
|
||||
NSData data = NSData.FromUrl(newUrl);
|
||||
Console.WriteLine("Data: {0}",data);
|
||||
});
|
||||
|
||||
// IMPORTANT! You must release the security lock established
|
||||
// above.
|
||||
pArgs.Url.StopAccessingSecurityScopedResource();
|
||||
};
|
||||
|
||||
// Display the document picker
|
||||
PresentViewController(args.DocumentPicker,true,null);
|
||||
};
|
||||
|
||||
pickerMenu.ModalPresentationStyle = UIModalPresentationStyle.Popover;
|
||||
PresentViewController(pickerMenu,true,null);
|
||||
UIPopoverPresentationController presentationPopover = pickerMenu.PopoverPresentationController;
|
||||
if (presentationPopover!=null) {
|
||||
presentationPopover.SourceView = this.View;
|
||||
presentationPopover.PermittedArrowDirections = UIPopoverArrowDirection.Down;
|
||||
presentationPopover.SourceRect = ((UIButton)s).Frame;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Views the will appear.
|
||||
/// </summary>
|
||||
/// <param name="animated">If set to <c>true</c> animated.</param>
|
||||
public override void ViewWillAppear (bool animated)
|
||||
{
|
||||
base.ViewWillAppear (animated);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Views the did appear.
|
||||
/// </summary>
|
||||
/// <param name="animated">If set to <c>true</c> animated.</param>
|
||||
public override void ViewDidAppear (bool animated)
|
||||
{
|
||||
base.ViewDidAppear (animated);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Views the will disappear.
|
||||
/// </summary>
|
||||
/// <param name="animated">If set to <c>true</c> animated.</param>
|
||||
public override void ViewWillDisappear (bool animated)
|
||||
{
|
||||
base.ViewWillDisappear (animated);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Views the did disappear.
|
||||
/// </summary>
|
||||
/// <param name="animated">If set to <c>true</c> animated.</param>
|
||||
public override void ViewDidDisappear (bool animated)
|
||||
{
|
||||
base.ViewDidDisappear (animated);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
// WARNING
|
||||
//
|
||||
// This file has been generated automatically by Xamarin Studio from the outlets and
|
||||
// actions declared in your storyboard file.
|
||||
// Manual changes to this file will not be maintained.
|
||||
//
|
||||
using System;
|
||||
using Foundation;
|
||||
using UIKit;
|
||||
using System.CodeDom.Compiler;
|
||||
|
||||
namespace DocPicker
|
||||
{
|
||||
[Register ("DocPickerViewController")]
|
||||
partial class DocPickerViewController
|
||||
{
|
||||
[Outlet]
|
||||
[GeneratedCode ("iOS Designer", "1.0")]
|
||||
UIBarButtonItem ActionButton { get; set; }
|
||||
|
||||
[Outlet]
|
||||
[GeneratedCode ("iOS Designer", "1.0")]
|
||||
UITextView DocumentText { get; set; }
|
||||
|
||||
[Outlet]
|
||||
[GeneratedCode ("iOS Designer", "1.0")]
|
||||
UIBarButtonItem SaveButton { get; set; }
|
||||
|
||||
void ReleaseDesignerOutlets ()
|
||||
{
|
||||
if (ActionButton != null) {
|
||||
ActionButton.Dispose ();
|
||||
ActionButton = null;
|
||||
}
|
||||
if (DocumentText != null) {
|
||||
DocumentText.Dispose ();
|
||||
DocumentText = null;
|
||||
}
|
||||
if (SaveButton != null) {
|
||||
SaveButton.Dispose ();
|
||||
SaveButton = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.developer.icloud-services</key>
|
||||
<array>
|
||||
<string>CloudDocuments</string>
|
||||
<string>CloudKit</string>
|
||||
</array>
|
||||
<key>com.apple.developer.ubiquity-kvstore-identifier</key>
|
||||
<string>$(TeamIdentifierPrefix)$(CFBundleIdentifier)</string>
|
||||
<key>com.apple.developer.icloud-container-identifiers</key>
|
||||
<array>
|
||||
<string>iCloud.com.xamarin.docpicker</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
|
@ -0,0 +1,67 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>DocPicker</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.xamarin.DocPicker</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1.0</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>MinimumOSVersion</key>
|
||||
<string>8.0</string>
|
||||
<key>UIDeviceFamily</key>
|
||||
<array>
|
||||
<integer>1</integer>
|
||||
<integer>2</integer>
|
||||
</array>
|
||||
<key>UIMainStoryboardFile</key>
|
||||
<string>MainStoryboard_iPhone</string>
|
||||
<key>UIMainStoryboardFile~ipad</key>
|
||||
<string>MainStoryboard_iPad</string>
|
||||
<key>UIRequiredDeviceCapabilities</key>
|
||||
<array>
|
||||
<string>armv7</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>UIPrerenderedIcon</key>
|
||||
<true/>
|
||||
<key>CFBundleIconFiles</key>
|
||||
<array>
|
||||
<string>Icon@2x</string>
|
||||
<string>Icon-60@2x</string>
|
||||
<string>Icon-72</string>
|
||||
<string>Icon-72@2x</string>
|
||||
<string>Icon-76</string>
|
||||
<string>Icon-76@2x</string>
|
||||
<string>Icon-Small</string>
|
||||
<string>Icon-Small@2x</string>
|
||||
<string>Icon-Small-50</string>
|
||||
<string>Icon-Small-50@2x</string>
|
||||
<string>Icon-Spotlight-40</string>
|
||||
<string>Icon-Spotlight-40@2x</string>
|
||||
<string>Icon</string>
|
||||
</array>
|
||||
<key>UIBackgroundModes</key>
|
||||
<array>
|
||||
<string>fetch</string>
|
||||
<string>remote-notification</string>
|
||||
</array>
|
||||
<key>NSUbiquitousContainerIsDocumentScopePublic</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
|
@ -0,0 +1,20 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using Foundation;
|
||||
using UIKit;
|
||||
|
||||
namespace DocPicker
|
||||
{
|
||||
public class Application
|
||||
{
|
||||
// This is the main entry point of the application.
|
||||
static void Main (string[] args)
|
||||
{
|
||||
// if you want to use a different Application Delegate class from "AppDelegate"
|
||||
// you can specify it here.
|
||||
UIApplication.Main (args, null, "AppDelegate");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,71 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="4451" systemVersion="13A461" targetRuntime="iOS.CocoaTouch.iPad" propertyAccessControl="none" useAutolayout="YES" initialViewController="BYZ-38-t0r">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3733"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--class Prefix:identifier View Controller-->
|
||||
<scene sceneID="tne-QT-ifu">
|
||||
<objects>
|
||||
<viewController id="BYZ-38-t0r" customClass="DocPickerViewController" sceneMemberID="viewController">
|
||||
<layoutGuides>
|
||||
<viewControllerLayoutGuide type="top" id="3"/>
|
||||
<viewControllerLayoutGuide type="bottom" id="4"/>
|
||||
</layoutGuides>
|
||||
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
|
||||
<rect key="frame" x="0.0" y="0.0" width="768" height="1024"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
|
||||
<subviews>
|
||||
<navigationBar contentMode="scaleToFill" id="5" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO">
|
||||
<rect key="frame" x="0.0" y="20" width="768" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
|
||||
<items>
|
||||
<navigationItem title="iCloud Document" id="6">
|
||||
<barButtonItem id="7" translatesAutoresizingMaskIntoConstraints="NO" key="rightBarButtonItem" systemItem="action"/>
|
||||
<barButtonItem id="8" translatesAutoresizingMaskIntoConstraints="NO" key="leftBarButtonItem" systemItem="save"/>
|
||||
</navigationItem>
|
||||
</items>
|
||||
</navigationBar>
|
||||
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" id="9" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO">
|
||||
<rect key="frame" x="0.0" y="65" width="768" height="959"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<string key="text">Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda.</string>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
|
||||
</textView>
|
||||
</subviews>
|
||||
</view>
|
||||
<connections>
|
||||
<outlet property="ActionButton" destination="7" id="name-outlet-7"/>
|
||||
<outlet property="SaveButton" destination="8" id="name-outlet-8"/>
|
||||
<outlet property="DocumentText" destination="9" id="name-outlet-9"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
</scene>
|
||||
</scenes>
|
||||
<simulatedMetricsContainer key="defaultSimulatedMetrics">
|
||||
<simulatedStatusBarMetrics key="statusBar" statusBarStyle="blackOpaque"/>
|
||||
<simulatedOrientationMetrics key="orientation"/>
|
||||
<simulatedScreenMetrics key="destination"/>
|
||||
</simulatedMetricsContainer>
|
||||
<resources>
|
||||
<image name="Default-568h.png" width="640" height="1136"/>
|
||||
<image name="Default-Landscape@2x~ipad.png" width="2048" height="1536"/>
|
||||
<image name="Default-Landscape~ipad.png" width="1024" height="768"/>
|
||||
<image name="Default-Portrait@2x~ipad.png" width="1536" height="2048"/>
|
||||
<image name="Default-Portrait~ipad.png" width="768" height="1024"/>
|
||||
<image name="Default.png" width="320" height="480"/>
|
||||
<image name="Icon-60.png" width="60" height="60"/>
|
||||
<image name="Icon-72.png" width="72" height="72"/>
|
||||
<image name="Icon-76.png" width="76" height="76"/>
|
||||
<image name="Icon-Small-50.png" width="50" height="50"/>
|
||||
<image name="Icon-Small.png" width="29" height="29"/>
|
||||
<image name="Icon-Spotlight-40.png" width="40" height="40"/>
|
||||
<image name="Icon.png" width="57" height="57"/>
|
||||
<image name="Logo.png" width="512" height="512"/>
|
||||
</resources>
|
||||
</document>
|
|
@ -0,0 +1,71 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="4451" systemVersion="13A461" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="vXZ-lx-hvc">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3733"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--class Prefix:identifier View Controller-->
|
||||
<scene sceneID="ufC-wZ-h7g">
|
||||
<objects>
|
||||
<viewController id="vXZ-lx-hvc" customClass="DocPickerViewController" sceneMemberID="viewController" storyboardIdentifier="DocPickerViewController" restorationIdentifier="DocPickerViewController">
|
||||
<layoutGuides>
|
||||
<viewControllerLayoutGuide type="top" id="3"/>
|
||||
<viewControllerLayoutGuide type="bottom" id="4"/>
|
||||
</layoutGuides>
|
||||
<view key="view" contentMode="scaleToFill" id="kh9-bI-dsS">
|
||||
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
|
||||
<subviews>
|
||||
<navigationBar contentMode="scaleToFill" id="5" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO">
|
||||
<rect key="frame" x="0.0" y="20" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMaxY="YES"/>
|
||||
<items>
|
||||
<navigationItem title="iCloud Document" id="6">
|
||||
<barButtonItem id="7" translatesAutoresizingMaskIntoConstraints="NO" key="rightBarButtonItem" systemItem="action"/>
|
||||
<barButtonItem id="9" translatesAutoresizingMaskIntoConstraints="NO" key="leftBarButtonItem" systemItem="save"/>
|
||||
</navigationItem>
|
||||
</items>
|
||||
</navigationBar>
|
||||
<textView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" id="8" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO">
|
||||
<rect key="frame" x="0.0" y="64" width="320" height="504"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
|
||||
<string key="text">Lorem ipsum dolor sit er elit lamet, consectetaur cillium adipisicing pecu, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Nam liber te conscient to factor tum poen legum odioque civiuda.</string>
|
||||
<fontDescription key="fontDescription" type="system" pointSize="14"/>
|
||||
<textInputTraits key="textInputTraits" autocapitalizationType="sentences"/>
|
||||
</textView>
|
||||
</subviews>
|
||||
</view>
|
||||
<connections>
|
||||
<outlet property="ActionButton" destination="7" id="name-outlet-7"/>
|
||||
<outlet property="DocumentText" destination="8" id="name-outlet-8"/>
|
||||
<outlet property="SaveButton" destination="9" id="name-outlet-9"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="x5A-6p-PRh" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
</scene>
|
||||
</scenes>
|
||||
<simulatedMetricsContainer key="defaultSimulatedMetrics">
|
||||
<simulatedStatusBarMetrics key="statusBar"/>
|
||||
<simulatedOrientationMetrics key="orientation"/>
|
||||
<simulatedScreenMetrics key="destination" type="retina4"/>
|
||||
</simulatedMetricsContainer>
|
||||
<resources>
|
||||
<image name="Default-568h.png" width="640" height="1136"/>
|
||||
<image name="Default-Landscape@2x~ipad.png" width="2048" height="1536"/>
|
||||
<image name="Default-Landscape~ipad.png" width="1024" height="768"/>
|
||||
<image name="Default-Portrait@2x~ipad.png" width="1536" height="2048"/>
|
||||
<image name="Default-Portrait~ipad.png" width="768" height="1024"/>
|
||||
<image name="Default.png" width="320" height="480"/>
|
||||
<image name="Icon-60.png" width="60" height="60"/>
|
||||
<image name="Icon-72.png" width="72" height="72"/>
|
||||
<image name="Icon-76.png" width="76" height="76"/>
|
||||
<image name="Icon-Small-50.png" width="50" height="50"/>
|
||||
<image name="Icon-Small.png" width="29" height="29"/>
|
||||
<image name="Icon-Spotlight-40.png" width="40" height="40"/>
|
||||
<image name="Icon.png" width="57" height="57"/>
|
||||
<image name="Logo.png" width="512" height="512"/>
|
||||
</resources>
|
||||
</document>
|
После Ширина: | Высота: | Размер: 61 KiB |
После Ширина: | Высота: | Размер: 22 KiB |
После Ширина: | Высота: | Размер: 28 KiB |
После Ширина: | Высота: | Размер: 21 KiB |
После Ширина: | Высота: | Размер: 42 KiB |
После Ширина: | Высота: | Размер: 14 KiB |
После Ширина: | Высота: | Размер: 38 KiB |
После Ширина: | Высота: | Размер: 4.8 KiB |
После Ширина: | Высота: | Размер: 7.0 KiB |
После Ширина: | Высота: | Размер: 5.4 KiB |
После Ширина: | Высота: | Размер: 8.0 KiB |
После Ширина: | Высота: | Размер: 5.5 KiB |
После Ширина: | Высота: | Размер: 8.2 KiB |
После Ширина: | Высота: | Размер: 4.4 KiB |
После Ширина: | Высота: | Размер: 6.3 KiB |
После Ширина: | Высота: | Размер: 3.6 KiB |
После Ширина: | Высота: | Размер: 4.7 KiB |
После Ширина: | Высота: | Размер: 4.0 KiB |
После Ширина: | Высота: | Размер: 5.5 KiB |
После Ширина: | Высота: | Размер: 3.2 KiB |
После Ширина: | Высота: | Размер: 6.8 KiB |
После Ширина: | Высота: | Размер: 20 KiB |
После Ширина: | Высота: | Размер: 54 KiB |
После Ширина: | Высота: | Размер: 27 KiB |
После Ширина: | Высота: | Размер: 54 KiB |
|
@ -0,0 +1,11 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<SampleMetadata>
|
||||
<ID>BB2DB100-5F0F-44F2-99D4-E414ED71C5AD</ID>
|
||||
<IsFullApplication>false</IsFullApplication>
|
||||
<Level>Intermediate</Level>
|
||||
<Tags>Platform Features, Cloud, Data, iOS8</Tags>
|
||||
<SupportedPlatforms>iOS</SupportedPlatforms>
|
||||
<LicenseRequirement>Indie</LicenseRequirement>
|
||||
<Gallery>true</Gallery>
|
||||
<Brief>DocPicker is a sample intended as a quick introduction to using the document Picker in iOS.</Brief>
|
||||
</SampleMetadata>
|
|
@ -0,0 +1,47 @@
|
|||
DocPicker
|
||||
======================
|
||||
|
||||
DocPicker accompanies to the [Introduction to the Document Picker](http://developer.xamarin.com/guides/ios/platform_features/introduction_to_the_document_picker/) guide in the developer portal.
|
||||
|
||||
## Setting up sample
|
||||
|
||||
To run this sample you need to have an app ID with CloudKit
|
||||
entitlements enabled and provisioning profile linked to it.
|
||||
|
||||
Follow the steps in the [Introduction to the Document Picker](http://developer.xamarin.com/guides/ios/platform_features/introduction_to_the_document_picker/#Enabling_iCloud_in_Xamarin) guide to set up your provisioning profile. These are also listed below.
|
||||
|
||||
If you don't have one please go to
|
||||
https://developer.apple.com/membercenter/index.action, select
|
||||
"Certificates, Identifiers & Profiles" and use the following
|
||||
instructions.
|
||||
|
||||
First of all, you should create an app ID. To do that, select "App
|
||||
ID's" in "Identifiers" section and then press add button at top-right
|
||||
corner of the screen.
|
||||
|
||||
* Enter app ID description, e.g.: "CloudKit Atlas sample"
|
||||
* Select "Explicit App ID" in App ID Suffix and enter bundle ID, e.g.:
|
||||
com.yourcompanyname.CloudKitAtlas
|
||||
* In App Services services section select iCloud, Include CloudKit support
|
||||
* Then press Continue button and check that everything is alright
|
||||
* Press Submit
|
||||
|
||||
On the second step we should create provisioning profile linked to
|
||||
newly created app ID. Select "All" in "Provisioning Profiles" section
|
||||
and then press add button at top-right corner of the screen.
|
||||
|
||||
* Select "iOS App Development" and press Continue button
|
||||
* Select newly created app ID in drop down list and press Continue button
|
||||
* Then select your team members and press Continue button
|
||||
* Select your devices and press Continue button
|
||||
* Enter profile name, e.g.: "CloudKit Atlas Development"
|
||||
* Download provisioning profile and then double click it to install
|
||||
|
||||
Finally, open sample in Xamarin Studio and open project settings.
|
||||
|
||||
* Set bundle identifier in "iOS Application" section and select
|
||||
provisioning profile created earlier in "iOS Bundle Signing".
|
||||
* Close project's options and select Entitlements.plist in project
|
||||
explorer then nable iCloud and check the CloudKit option.
|
||||
* Make sure you are signed into your iCloud account in the simulator
|
||||
or device before running the app.
|
После Ширина: | Высота: | Размер: 43 KiB |
После Ширина: | Высота: | Размер: 48 KiB |
После Ширина: | Высота: | Размер: 126 KiB |
После Ширина: | Высота: | Размер: 63 KiB |