[LifecycleDemo]Adding new sample for docs
|
@ -0,0 +1,35 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual Studio 2010
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LifecycleDemo", "LifecycleDemo\LifecycleDemo.csproj", "{286ABE0C-4DAD-41B3-A66C-E37DE63F15F7}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
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
|
||||
{286ABE0C-4DAD-41B3-A66C-E37DE63F15F7}.Ad-Hoc|iPhone.ActiveCfg = Ad-Hoc|iPhone
|
||||
{286ABE0C-4DAD-41B3-A66C-E37DE63F15F7}.Ad-Hoc|iPhone.Build.0 = Ad-Hoc|iPhone
|
||||
{286ABE0C-4DAD-41B3-A66C-E37DE63F15F7}.AppStore|iPhone.ActiveCfg = AppStore|iPhone
|
||||
{286ABE0C-4DAD-41B3-A66C-E37DE63F15F7}.AppStore|iPhone.Build.0 = AppStore|iPhone
|
||||
{286ABE0C-4DAD-41B3-A66C-E37DE63F15F7}.Debug|Any CPU.ActiveCfg = Debug|iPhoneSimulator
|
||||
{286ABE0C-4DAD-41B3-A66C-E37DE63F15F7}.Debug|Any CPU.Build.0 = Debug|iPhoneSimulator
|
||||
{286ABE0C-4DAD-41B3-A66C-E37DE63F15F7}.Debug|iPhone.ActiveCfg = Debug|iPhone
|
||||
{286ABE0C-4DAD-41B3-A66C-E37DE63F15F7}.Debug|iPhone.Build.0 = Debug|iPhone
|
||||
{286ABE0C-4DAD-41B3-A66C-E37DE63F15F7}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
|
||||
{286ABE0C-4DAD-41B3-A66C-E37DE63F15F7}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
|
||||
{286ABE0C-4DAD-41B3-A66C-E37DE63F15F7}.Release|Any CPU.ActiveCfg = Release|iPhoneSimulator
|
||||
{286ABE0C-4DAD-41B3-A66C-E37DE63F15F7}.Release|Any CPU.Build.0 = Release|iPhoneSimulator
|
||||
{286ABE0C-4DAD-41B3-A66C-E37DE63F15F7}.Release|iPhone.ActiveCfg = Release|iPhone
|
||||
{286ABE0C-4DAD-41B3-A66C-E37DE63F15F7}.Release|iPhone.Build.0 = Release|iPhone
|
||||
{286ABE0C-4DAD-41B3-A66C-E37DE63F15F7}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
|
||||
{286ABE0C-4DAD-41B3-A66C-E37DE63F15F7}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,58 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using Foundation;
|
||||
using UIKit;
|
||||
|
||||
namespace Lifecycle.iOS
|
||||
{
|
||||
[Register("AppDelegate")]
|
||||
public partial class AppDelegate : UIApplicationDelegate
|
||||
{
|
||||
//Recall that AppDelegate subscribes to events from the system (subscribes to iOS events)
|
||||
|
||||
UIWindow window;
|
||||
AppLifecycleViewController viewController;
|
||||
|
||||
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
|
||||
{
|
||||
window = new UIWindow(UIScreen.MainScreen.Bounds);
|
||||
|
||||
viewController = new AppLifecycleViewController();
|
||||
window.RootViewController = viewController;
|
||||
|
||||
window.MakeKeyAndVisible();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void OnActivated(UIApplication application)
|
||||
{
|
||||
Console.WriteLine("OnActivated called, App is active.");
|
||||
}
|
||||
|
||||
public override void WillEnterForeground(UIApplication application)
|
||||
{
|
||||
Console.WriteLine("App will enter foreground");
|
||||
}
|
||||
|
||||
public override void OnResignActivation(UIApplication application)
|
||||
{
|
||||
Console.WriteLine("OnResignActivation called, App moving to inactive state.");
|
||||
}
|
||||
|
||||
public override void DidEnterBackground(UIApplication application)
|
||||
{
|
||||
Console.WriteLine("App entering background state.");
|
||||
}
|
||||
|
||||
// [not guaranteed that this will run]
|
||||
public override void WillTerminate(UIApplication application)
|
||||
{
|
||||
Console.WriteLine("App is terminating.");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
using System;
|
||||
using UIKit;
|
||||
using CoreGraphics;
|
||||
|
||||
namespace Lifecycle.iOS
|
||||
{
|
||||
public class AppLifecycleViewController : UIViewController
|
||||
{
|
||||
UILabel label;
|
||||
nfloat labelWidth = 300;
|
||||
nfloat labelHeight = 200;
|
||||
|
||||
public AppLifecycleViewController()
|
||||
{
|
||||
}
|
||||
|
||||
public override void ViewDidLoad()
|
||||
{
|
||||
base.ViewDidLoad();
|
||||
|
||||
View.Frame = UIScreen.MainScreen.Bounds;
|
||||
View.BackgroundColor = UIColor.White;
|
||||
View.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
|
||||
|
||||
var frame = new CGRect(
|
||||
View.Frame.Width / 2 - labelWidth / 2,
|
||||
View.Frame.Height / 2 - labelHeight / 2,
|
||||
labelWidth,
|
||||
labelHeight);
|
||||
|
||||
label = new UILabel(frame);
|
||||
|
||||
label.Text = "App Lifecycle Demo";
|
||||
label.Font = UIFont.FromName("Helvetica-Bold", 50f);
|
||||
label.AdjustsFontSizeToFitWidth = true;
|
||||
|
||||
// here we can use a notification to let us know when the app has entered the foreground
|
||||
// from the background, and update the text in the View
|
||||
// this causes a flicker, but we will use it for demo purposes
|
||||
UIApplication.Notifications.ObserveWillEnterForeground ((sender, args) => {
|
||||
label.Text = "Welcome back!";
|
||||
});
|
||||
|
||||
|
||||
View.AddSubview(label);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
<?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>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>CFBundleIconFiles</key>
|
||||
<array>
|
||||
<string>Icon-Small</string>
|
||||
<string>Icon-Small@2x</string>
|
||||
<string>Icon-Small-50</string>
|
||||
<string>Icon</string>
|
||||
<string>Icon@2x</string>
|
||||
<string>Icon-72</string>
|
||||
</array>
|
||||
<key>MinimumOSVersion</key>
|
||||
<string>5.1.1</string>
|
||||
<key>CFBundleDisplayName</key>
|
||||
<string>Lifecycle Demo</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.xamarin.LifecycleDemo</string>
|
||||
</dict>
|
||||
</plist>
|
|
@ -0,0 +1,129 @@
|
|||
<?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>
|
||||
<ProductVersion>8.0.30703</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{286ABE0C-4DAD-41B3-A66C-E37DE63F15F7}</ProjectGuid>
|
||||
<ProjectTypeGuids>{FEACFBD2-3405-455C-9665-78FE426C6842};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>Location.iOS</RootNamespace>
|
||||
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
|
||||
<AssemblyName>LocationiOS</AssemblyName>
|
||||
<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>
|
||||
<MtouchDebug>true</MtouchDebug>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\iPhoneSimulator\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<MtouchLink>None</MtouchLink>
|
||||
</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>
|
||||
<MtouchDebug>true</MtouchDebug>
|
||||
<CodesignKey>iPhone Developer</CodesignKey>
|
||||
<MtouchArch>ARMv7</MtouchArch>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\iPhone\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<CodesignKey>iPhone Developer</CodesignKey>
|
||||
<MtouchArch>ARMv7, ARM64</MtouchArch>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Ad-Hoc|iPhone' ">
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\iPhone\Ad-Hoc</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<BuildIpa>true</BuildIpa>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<CodesignProvision>Automatic:AdHoc</CodesignProvision>
|
||||
<CodesignKey>iPhone Distribution</CodesignKey>
|
||||
<MtouchArch>ARMv7, ARM64</MtouchArch>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'AppStore|iPhone' ">
|
||||
<DebugType>none</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\iPhone\AppStore</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<CodesignKey>iPhone Distribution</CodesignKey>
|
||||
<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>
|
||||
<Folder Include="Resources\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Info.plist" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Main.cs" />
|
||||
<Compile Include="AppDelegate.cs" />
|
||||
<Compile Include="AppLifecycleViewController.cs" />
|
||||
</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-29.png" />
|
||||
<BundleResource Include="Resources\icon-50.png" />
|
||||
<BundleResource Include="Resources\icon-57.png" />
|
||||
<BundleResource Include="Resources\icon-58.png" />
|
||||
<BundleResource Include="Resources\icon-72.png" />
|
||||
<BundleResource Include="Resources\icon-100.png" />
|
||||
<BundleResource Include="Resources\icon-114.png" />
|
||||
<BundleResource Include="Resources\icon-144.png" />
|
||||
<BundleResource Include="Resources\iTunesArtwork%402x.png" />
|
||||
<BundleResource Include="Resources\Icon-Small.png" />
|
||||
<BundleResource Include="Resources\Icon-Small%402x.png" />
|
||||
<BundleResource Include="Resources\Icon-Small-50.png" />
|
||||
<BundleResource Include="Resources\Icon.png" />
|
||||
<BundleResource Include="Resources\Icon%402x.png" />
|
||||
<BundleResource Include="Resources\Icon-72.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ITunesArtwork Include="Resources\iTunesArtwork.png" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\iOS\Xamarin.iOS.CSharp.targets" />
|
||||
</Project>
|
|
@ -0,0 +1,20 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using Foundation;
|
||||
using UIKit;
|
||||
|
||||
namespace Lifecycle.iOS
|
||||
{
|
||||
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");
|
||||
}
|
||||
}
|
||||
}
|
После Ширина: | Высота: | Размер: 12 KiB |
После Ширина: | Высота: | Размер: 24 KiB |
После Ширина: | Высота: | Размер: 9.4 KiB |
После Ширина: | Высота: | Размер: 25 KiB |
После Ширина: | Высота: | Размер: 9.8 KiB |
После Ширина: | Высота: | Размер: 5.2 KiB |
После Ширина: | Высота: | Размер: 12 KiB |
После Ширина: | Высота: | Размер: 4.2 KiB |
После Ширина: | Высота: | Размер: 2.0 KiB |
После Ширина: | Высота: | Размер: 5.2 KiB |
После Ширина: | Высота: | Размер: 5.1 KiB |
После Ширина: | Высота: | Размер: 14 KiB |
После Ширина: | Высота: | Размер: 106 KiB |
После Ширина: | Высота: | Размер: 273 KiB |
После Ширина: | Высота: | Размер: 11 KiB |
После Ширина: | Высота: | Размер: 14 KiB |
После Ширина: | Высота: | Размер: 18 KiB |
После Ширина: | Высота: | Размер: 2.0 KiB |
После Ширина: | Высота: | Размер: 4.2 KiB |
После Ширина: | Высота: | Размер: 5.1 KiB |
После Ширина: | Высота: | Размер: 5.2 KiB |
После Ширина: | Высота: | Размер: 6.6 KiB |
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<SampleMetadata>
|
||||
<ID>89744C6F-EC17-4F5D-B679-6FB3B1D7E6D1</ID>
|
||||
<IsFullApplication>false</IsFullApplication>
|
||||
<Level>starter</Level>
|
||||
<Tags>Backgrounding</Tags>
|
||||
<Gallery>false</Gallery>
|
||||
<Brief>Sample shows the iOS application lifecycle.</Brief>
|
||||
</SampleMetadata>
|
|
@ -0,0 +1,5 @@
|
|||
LifeCycle Demo
|
||||
==========
|
||||
|
||||
This basic sample relates to the [iOS Backgrounding](http://developer.xamarin.com/guides/ios/application_fundamentals/backgrounding/) guides in the developers centre. It adds location to the `AppDelegate` to display when an application is entering a given state. You can find out more information about this by visiting the [Part 2- Application Lifecycle Demo](/guides/ios/application_fundamentals/backgrounding/part_2_application_lifecycle_demo/) guide.
|
||||
|
После Ширина: | Высота: | Размер: 116 KiB |
После Ширина: | Высота: | Размер: 19 KiB |