Add SimpleBackgroundFetch sample
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<SampleMetadata>
|
||||
<ID>4cb99018-11e0-4a32-af0b-12d9852ead7d</ID>
|
||||
<IsFullApplication>false</IsFullApplication>
|
||||
<Level>Intermediate</Level>
|
||||
<Tags>Backgrounding</Tags>
|
||||
<LicenseRequirement>Indie</LicenseRequirement>
|
||||
</SampleMetadata>
|
|
@ -0,0 +1,7 @@
|
|||
SimpleBackgroundFetch
|
||||
==============
|
||||
This sample demostrates how to handle background fetches when the app is not running.
|
||||
|
||||
Authors
|
||||
-------
|
||||
Timothy Risi
|
|
@ -0,0 +1,32 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 11.00
|
||||
# Visual Studio 2010
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleBackgroundFetch", "SimpleBackgroundFetch\SimpleBackgroundFetch.csproj", "{7CA95A29-6CC2-4A61-8AF8-3669983E9A74}"
|
||||
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
|
||||
{7CA95A29-6CC2-4A61-8AF8-3669983E9A74}.Ad-Hoc|iPhone.ActiveCfg = Ad-Hoc|iPhone
|
||||
{7CA95A29-6CC2-4A61-8AF8-3669983E9A74}.Ad-Hoc|iPhone.Build.0 = Ad-Hoc|iPhone
|
||||
{7CA95A29-6CC2-4A61-8AF8-3669983E9A74}.AppStore|iPhone.ActiveCfg = AppStore|iPhone
|
||||
{7CA95A29-6CC2-4A61-8AF8-3669983E9A74}.AppStore|iPhone.Build.0 = AppStore|iPhone
|
||||
{7CA95A29-6CC2-4A61-8AF8-3669983E9A74}.Debug|iPhone.ActiveCfg = Debug|iPhone
|
||||
{7CA95A29-6CC2-4A61-8AF8-3669983E9A74}.Debug|iPhone.Build.0 = Debug|iPhone
|
||||
{7CA95A29-6CC2-4A61-8AF8-3669983E9A74}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
|
||||
{7CA95A29-6CC2-4A61-8AF8-3669983E9A74}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
|
||||
{7CA95A29-6CC2-4A61-8AF8-3669983E9A74}.Release|iPhone.ActiveCfg = Release|iPhone
|
||||
{7CA95A29-6CC2-4A61-8AF8-3669983E9A74}.Release|iPhone.Build.0 = Release|iPhone
|
||||
{7CA95A29-6CC2-4A61-8AF8-3669983E9A74}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
|
||||
{7CA95A29-6CC2-4A61-8AF8-3669983E9A74}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
|
||||
EndGlobalSection
|
||||
GlobalSection(MonoDevelopProperties) = preSolution
|
||||
StartupItem = SimpleBackgroundFetch\SimpleBackgroundFetch.csproj
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,42 @@
|
|||
using System;
|
||||
using MonoTouch.Foundation;
|
||||
using MonoTouch.UIKit;
|
||||
|
||||
namespace SimpleBackgroundFetch
|
||||
{
|
||||
// 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
|
||||
{
|
||||
// class-level declarations
|
||||
public override UIWindow Window {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public override bool FinishedLaunching (UIApplication application, NSDictionary launchOptions)
|
||||
{
|
||||
UIApplication.SharedApplication.SetMinimumBackgroundFetchInterval (UIApplication.BackgroundFetchIntervalMinimum);
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void PerformFetch (UIApplication application, Action<UIBackgroundFetchResult> completionHandler)
|
||||
{
|
||||
UINavigationController navigationController = Window.RootViewController as UINavigationController;
|
||||
UIViewController topViewController = navigationController.TopViewController;
|
||||
if (topViewController is RootViewController) {
|
||||
(topViewController as RootViewController).InsertNewObjectForFetch (completionHandler);
|
||||
UIApplication.SharedApplication.ApplicationIconBadgeNumber++;
|
||||
} else
|
||||
completionHandler (UIBackgroundFetchResult.Failed);
|
||||
}
|
||||
|
||||
public override void WillEnterForeground (UIApplication application)
|
||||
{
|
||||
UIApplication.SharedApplication.ApplicationIconBadgeNumber = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
using System;
|
||||
using System.Drawing;
|
||||
using System.Collections.Generic;
|
||||
using MonoTouch.Foundation;
|
||||
using MonoTouch.UIKit;
|
||||
|
||||
namespace SimpleBackgroundFetch
|
||||
{
|
||||
public partial class DetailViewController : UIViewController
|
||||
{
|
||||
object detailItem;
|
||||
|
||||
public DetailViewController (IntPtr handle) : base (handle)
|
||||
{
|
||||
}
|
||||
|
||||
public void SetDetailItem (object newDetailItem)
|
||||
{
|
||||
if (detailItem != newDetailItem) {
|
||||
detailItem = newDetailItem;
|
||||
|
||||
// Update the view
|
||||
ConfigureView ();
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigureView ()
|
||||
{
|
||||
// Update the user interface for the detail item
|
||||
if (IsViewLoaded && detailItem != null)
|
||||
detailDescriptionLabel.Text = detailItem.ToString ();
|
||||
}
|
||||
|
||||
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.
|
||||
}
|
||||
|
||||
public override void ViewDidLoad ()
|
||||
{
|
||||
base.ViewDidLoad ();
|
||||
|
||||
// Perform any additional setup after loading the view, typically from a nib.
|
||||
ConfigureView ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
33
SimpleBackgroundFetch/SimpleBackgroundFetch/DetailViewController.designer.cs
сгенерированный
Normal file
|
@ -0,0 +1,33 @@
|
|||
//
|
||||
// This file has been generated automatically by MonoDevelop to store outlets and
|
||||
// actions made in the Xcode designer. If it is removed, they will be lost.
|
||||
// Manual changes to this file may not be handled correctly.
|
||||
//
|
||||
using MonoTouch.Foundation;
|
||||
|
||||
namespace SimpleBackgroundFetch
|
||||
{
|
||||
[Register ("DetailViewController")]
|
||||
partial class DetailViewController
|
||||
{
|
||||
[Outlet]
|
||||
MonoTouch.UIKit.UILabel detailDescriptionLabel { get; set; }
|
||||
|
||||
[Outlet]
|
||||
MonoTouch.UIKit.UIToolbar toolbar { get; set; }
|
||||
|
||||
void ReleaseDesignerOutlets ()
|
||||
{
|
||||
if (detailDescriptionLabel != null) {
|
||||
detailDescriptionLabel.Dispose ();
|
||||
detailDescriptionLabel = null;
|
||||
}
|
||||
|
||||
if (toolbar != null) {
|
||||
toolbar.Dispose ();
|
||||
toolbar = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
<?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>UIMainStoryboardFile</key>
|
||||
<string>MainStoryboard</string>
|
||||
<key>MinimumOSVersion</key>
|
||||
<string>5.0</string>
|
||||
<key>UIBackgroundModes</key>
|
||||
<array>
|
||||
<string>fetch</string>
|
||||
</array>
|
||||
<key>XSAppIconAssets</key>
|
||||
<string>Resources/Images.xcassets/AppIcons.appiconset</string>
|
||||
<key>XSLaunchImageAssets</key>
|
||||
<string>Resources/Images.xcassets/LaunchImage.launchimage</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.xamarin.examples.simplebackgroundfetch</string>
|
||||
</dict>
|
||||
</plist>
|
|
@ -0,0 +1,19 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MonoTouch.Foundation;
|
||||
using MonoTouch.UIKit;
|
||||
|
||||
namespace SimpleBackgroundFetch
|
||||
{
|
||||
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,114 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="4457.6" systemVersion="12E55" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" initialViewController="3">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3682.6"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--Navigation Controller-->
|
||||
<scene sceneID="11">
|
||||
<objects>
|
||||
<navigationController id="3" sceneMemberID="viewController">
|
||||
<extendedEdge key="edgesForExtendedLayout"/>
|
||||
<navigationBar key="navigationBar" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" id="4">
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</navigationBar>
|
||||
<connections>
|
||||
<segue destination="12" kind="relationship" relationship="rootViewController" id="19"/>
|
||||
</connections>
|
||||
</navigationController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="10" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="-1" y="64"/>
|
||||
</scene>
|
||||
<!--Root View Controller - Master-->
|
||||
<scene sceneID="18">
|
||||
<objects>
|
||||
<tableViewController storyboardIdentifier="master" title="Master" id="12" customClass="RootViewController" sceneMemberID="viewController">
|
||||
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="Uo7-s2-71Y">
|
||||
<rect key="frame" x="0.0" y="64" width="320" height="416"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<prototypes>
|
||||
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" accessoryType="disclosureIndicator" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="DataSourceCell" textLabel="7AW-xI-J0e" style="IBUITableViewCellStyleDefault" id="QcF-aY-uLW">
|
||||
<rect key="frame" x="0.0" y="22" width="320" height="44"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<view key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center">
|
||||
<rect key="frame" x="0.0" y="0.0" width="287" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<label opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="left" text="Title" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="7AW-xI-J0e">
|
||||
<rect key="frame" x="15" y="0.0" width="270" height="43"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<fontDescription key="fontDescription" type="boldSystem" pointSize="20"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<color key="highlightedColor" red="1" green="1" blue="1" alpha="1" colorSpace="calibratedRGB"/>
|
||||
</label>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<connections>
|
||||
<segue destination="21" kind="push" identifier="showDetail" id="Dns-Xv-dPR"/>
|
||||
</connections>
|
||||
</tableViewCell>
|
||||
</prototypes>
|
||||
<connections>
|
||||
<outlet property="dataSource" destination="12" id="feg-Ja-qFF"/>
|
||||
<outlet property="delegate" destination="12" id="7aM-Pb-dsE"/>
|
||||
</connections>
|
||||
</tableView>
|
||||
<extendedEdge key="edgesForExtendedLayout"/>
|
||||
<navigationItem key="navigationItem" title="Master" id="35"/>
|
||||
</tableViewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="17" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="455" y="64"/>
|
||||
</scene>
|
||||
<!--Detail View Controller - Detail-->
|
||||
<scene sceneID="24">
|
||||
<objects>
|
||||
<viewController storyboardIdentifier="detail" title="Detail" id="21" customClass="DetailViewController" sceneMemberID="viewController">
|
||||
<view key="view" contentMode="scaleToFill" id="22">
|
||||
<rect key="frame" x="0.0" y="64" width="320" height="416"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
|
||||
<subviews>
|
||||
<label clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" text="Detail view content goes here" textAlignment="center" lineBreakMode="tailTruncation" minimumFontSize="10" id="27">
|
||||
<rect key="frame" x="20" y="199" width="280" height="18"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES" flexibleMaxY="YES"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<fontDescription key="fontDescription" type="system" size="system"/>
|
||||
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
|
||||
<nil key="highlightedColor"/>
|
||||
</label>
|
||||
</subviews>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
|
||||
</view>
|
||||
<extendedEdge key="edgesForExtendedLayout"/>
|
||||
<navigationItem key="navigationItem" title="Detail" id="26"/>
|
||||
<connections>
|
||||
<outlet property="detailDescriptionLabel" destination="27" id="28"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
<placeholder placeholderIdentifier="IBFirstResponder" id="23" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="924" y="64"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
<classes>
|
||||
<class className="DetailViewController" superclassName="UIViewController">
|
||||
<source key="sourceIdentifier" type="project" relativePath="./Classes/DetailViewController.h"/>
|
||||
<relationships>
|
||||
<relationship kind="outlet" name="detailDescriptionLabel" candidateClass="UILabel"/>
|
||||
<relationship kind="outlet" name="toolbar" candidateClass="UIToolbar"/>
|
||||
</relationships>
|
||||
</class>
|
||||
<class className="RootViewController" superclassName="UITableViewController">
|
||||
<source key="sourceIdentifier" type="project" relativePath="./Classes/RootViewController.h"/>
|
||||
</class>
|
||||
</classes>
|
||||
<simulatedMetricsContainer key="defaultSimulatedMetrics">
|
||||
<simulatedStatusBarMetrics key="statusBar"/>
|
||||
<simulatedOrientationMetrics key="orientation"/>
|
||||
<simulatedScreenMetrics key="destination"/>
|
||||
</simulatedMetricsContainer>
|
||||
</document>
|
|
@ -0,0 +1 @@
|
|||
{"images":[{"idiom":"iphone","filename":"Icon.png","size":"57x57","scale":"1x"},{"idiom":"iphone","filename":"Icon@2x.png","size":"57x57","scale":"2x"},{"idiom":"iphone","filename":"Icon-60@2x.png","size":"60x60","scale":"2x"},{"idiom":"iphone","filename":"Icon-Small.png","size":"29x29","scale":"1x"},{"idiom":"iphone","filename":"Icon-Small@2x.png","size":"29x29","scale":"2x"},{"idiom":"iphone","filename":"Icon-Small-40@2x.png","size":"40x40","scale":"2x"}],"info":{"version":1,"author":"xcode"}}
|
Двоичные данные
SimpleBackgroundFetch/SimpleBackgroundFetch/Resources/Images.xcassets/AppIcons.appiconset/Icon-60@2x.png
Normal file
После Ширина: | Высота: | Размер: 15 KiB |
Двоичные данные
SimpleBackgroundFetch/SimpleBackgroundFetch/Resources/Images.xcassets/AppIcons.appiconset/Icon-Small-40@2x.png
Normal file
После Ширина: | Высота: | Размер: 8.6 KiB |
Двоичные данные
SimpleBackgroundFetch/SimpleBackgroundFetch/Resources/Images.xcassets/AppIcons.appiconset/Icon-Small.png
Normal file
После Ширина: | Высота: | Размер: 2.0 KiB |
Двоичные данные
SimpleBackgroundFetch/SimpleBackgroundFetch/Resources/Images.xcassets/AppIcons.appiconset/Icon-Small@2x.png
Normal file
После Ширина: | Высота: | Размер: 5.2 KiB |
Двоичные данные
SimpleBackgroundFetch/SimpleBackgroundFetch/Resources/Images.xcassets/AppIcons.appiconset/Icon.png
Normal file
После Ширина: | Высота: | Размер: 5.1 KiB |
Двоичные данные
SimpleBackgroundFetch/SimpleBackgroundFetch/Resources/Images.xcassets/AppIcons.appiconset/Icon@2x.png
Normal file
После Ширина: | Высота: | Размер: 14 KiB |
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
"images": [
|
||||
{
|
||||
"orientation": "portrait",
|
||||
"idiom": "iphone",
|
||||
"extent": "full-screen",
|
||||
"filename": "Default.png",
|
||||
"size": "320x480",
|
||||
"scale": "1x"
|
||||
},
|
||||
{
|
||||
"orientation": "portrait",
|
||||
"idiom": "iphone",
|
||||
"extent": "full-screen",
|
||||
"filename": "Default@2x.png",
|
||||
"size": "320x480",
|
||||
"scale": "2x"
|
||||
},
|
||||
{
|
||||
"orientation": "portrait",
|
||||
"idiom": "iphone",
|
||||
"extent": "full-screen",
|
||||
"filename": "Default-568h@2x.png",
|
||||
"size": "320x568",
|
||||
"subtype": "retina4",
|
||||
"scale": "2x"
|
||||
}
|
||||
],
|
||||
"info": {
|
||||
"version": 1,
|
||||
"author": "xcode"
|
||||
}
|
||||
}
|
После Ширина: | Высота: | Размер: 12 KiB |
Двоичные данные
SimpleBackgroundFetch/SimpleBackgroundFetch/Resources/Images.xcassets/LaunchImage.launchimage/Default.png
Normal file
После Ширина: | Высота: | Размер: 5.2 KiB |
Двоичные данные
SimpleBackgroundFetch/SimpleBackgroundFetch/Resources/Images.xcassets/LaunchImage.launchimage/Default@2x.png
Normal file
После Ширина: | Высота: | Размер: 12 KiB |
|
@ -0,0 +1,133 @@
|
|||
using System;
|
||||
using System.Drawing;
|
||||
using System.Collections.Generic;
|
||||
using MonoTouch.Foundation;
|
||||
using MonoTouch.UIKit;
|
||||
|
||||
namespace SimpleBackgroundFetch
|
||||
{
|
||||
public partial class RootViewController : UITableViewController
|
||||
{
|
||||
DataSource dataSource;
|
||||
|
||||
public RootViewController (IntPtr handle) : base (handle)
|
||||
{
|
||||
Title = NSBundle.MainBundle.LocalizedString ("Master", "Master");
|
||||
|
||||
// Custom initialization
|
||||
}
|
||||
|
||||
public void InsertNewObjectForFetch (Action<UIBackgroundFetchResult> completionhandler)
|
||||
{
|
||||
AddNewItem (null, EventArgs.Empty);
|
||||
|
||||
completionhandler (UIBackgroundFetchResult.NewData);
|
||||
}
|
||||
|
||||
void AddNewItem (object sender, EventArgs args)
|
||||
{
|
||||
dataSource.Objects.Insert (0, DateTime.Now);
|
||||
|
||||
using (var indexPath = NSIndexPath.FromRowSection (0, 0))
|
||||
TableView.InsertRows (new NSIndexPath[] { indexPath }, UITableViewRowAnimation.Automatic);
|
||||
}
|
||||
|
||||
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.
|
||||
}
|
||||
|
||||
public override void ViewDidLoad ()
|
||||
{
|
||||
base.ViewDidLoad ();
|
||||
|
||||
// Perform any additional setup after loading the view, typically from a nib.
|
||||
NavigationItem.LeftBarButtonItem = EditButtonItem;
|
||||
|
||||
var addButton = new UIBarButtonItem (UIBarButtonSystemItem.Add, AddNewItem);
|
||||
NavigationItem.RightBarButtonItem = addButton;
|
||||
|
||||
TableView.Source = dataSource = new DataSource (this);
|
||||
}
|
||||
|
||||
class DataSource : UITableViewSource
|
||||
{
|
||||
static readonly NSString CellIdentifier = new NSString ("DataSourceCell");
|
||||
List<object> objects = new List<object> ();
|
||||
RootViewController controller;
|
||||
|
||||
public DataSource (RootViewController controller)
|
||||
{
|
||||
this.controller = controller;
|
||||
}
|
||||
|
||||
public IList<object> Objects {
|
||||
get { return objects; }
|
||||
}
|
||||
// Customize the number of sections in the table view.
|
||||
public override int NumberOfSections (UITableView tableView)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
public override int RowsInSection (UITableView tableview, int section)
|
||||
{
|
||||
return objects.Count;
|
||||
}
|
||||
// Customize the appearance of table view cells.
|
||||
public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath)
|
||||
{
|
||||
var cell = (UITableViewCell)tableView.DequeueReusableCell (CellIdentifier, indexPath);
|
||||
|
||||
cell.TextLabel.Text = objects [indexPath.Row].ToString ();
|
||||
|
||||
return cell;
|
||||
}
|
||||
|
||||
public override bool CanEditRow (UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath)
|
||||
{
|
||||
// Return false if you do not want the specified item to be editable.
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void CommitEditingStyle (UITableView tableView, UITableViewCellEditingStyle editingStyle, NSIndexPath indexPath)
|
||||
{
|
||||
if (editingStyle == UITableViewCellEditingStyle.Delete) {
|
||||
// Delete the row from the data source.
|
||||
objects.RemoveAt (indexPath.Row);
|
||||
controller.TableView.DeleteRows (new NSIndexPath[] { indexPath }, UITableViewRowAnimation.Fade);
|
||||
} else if (editingStyle == UITableViewCellEditingStyle.Insert) {
|
||||
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view.
|
||||
}
|
||||
}
|
||||
/*
|
||||
// Override to support rearranging the table view.
|
||||
public override void MoveRow (UITableView tableView, NSIndexPath sourceIndexPath, NSIndexPath destinationIndexPath)
|
||||
{
|
||||
}
|
||||
*/
|
||||
/*
|
||||
// Override to support conditional rearranging of the table view.
|
||||
public override bool CanMoveRow (UITableView tableView, NSIndexPath indexPath)
|
||||
{
|
||||
// Return false if you do not want the item to be re-orderable.
|
||||
return true;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public override void PrepareForSegue (UIStoryboardSegue segue, NSObject sender)
|
||||
{
|
||||
if (segue.Identifier == "showDetail") {
|
||||
var indexPath = TableView.IndexPathForSelectedRow;
|
||||
var item = dataSource.Objects [indexPath.Row];
|
||||
|
||||
((DetailViewController)segue.DestinationViewController).SetDetailItem (item);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
19
SimpleBackgroundFetch/SimpleBackgroundFetch/RootViewController.designer.cs
сгенерированный
Normal file
|
@ -0,0 +1,19 @@
|
|||
// WARNING
|
||||
//
|
||||
// This file has been generated automatically by Xamarin Studio to store outlets and
|
||||
// actions made in the UI designer. If it is removed, they will be lost.
|
||||
// Manual changes to this file may not be handled correctly.
|
||||
//
|
||||
using MonoTouch.Foundation;
|
||||
using System.CodeDom.Compiler;
|
||||
|
||||
namespace SimpleBackgroundFetch
|
||||
{
|
||||
[Register ("RootViewController")]
|
||||
partial class RootViewController
|
||||
{
|
||||
void ReleaseDesignerOutlets ()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,128 @@
|
|||
<?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>10.0.0</ProductVersion>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
<ProjectGuid>{7CA95A29-6CC2-4A61-8AF8-3669983E9A74}</ProjectGuid>
|
||||
<ProjectTypeGuids>{6BC8ED88-2882-458C-8E55-DFD12B67127B};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>SimpleBackgroundFetch</RootNamespace>
|
||||
<IPhoneResourcePrefix>Resources</IPhoneResourcePrefix>
|
||||
<AssemblyName>SimpleBackgroundFetch</AssemblyName>
|
||||
</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>
|
||||
<MtouchLink>None</MtouchLink>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<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>
|
||||
</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>
|
||||
<MtouchDebug>true</MtouchDebug>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<CodesignKey>iPhone Developer</CodesignKey>
|
||||
<IpaPackageName>
|
||||
</IpaPackageName>
|
||||
<MtouchI18n>
|
||||
</MtouchI18n>
|
||||
<MtouchArch>ARMv7</MtouchArch>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\iPhone\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<CodesignKey>iPhone Developer</CodesignKey>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
</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>
|
||||
<CodesignKey>iPhone Distribution</CodesignKey>
|
||||
<BuildIpa>true</BuildIpa>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<CodesignProvision>Automatic:AdHoc</CodesignProvision>
|
||||
</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>
|
||||
<ConsolePause>false</ConsolePause>
|
||||
<CodesignProvision>Automatic:AppStore</CodesignProvision>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="monotouch" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Resources\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Info.plist" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Main.cs" />
|
||||
<Compile Include="AppDelegate.cs" />
|
||||
<Compile Include="RootViewController.cs" />
|
||||
<Compile Include="RootViewController.designer.cs">
|
||||
<DependentUpon>RootViewController.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="DetailViewController.cs" />
|
||||
<Compile Include="DetailViewController.designer.cs">
|
||||
<DependentUpon>DetailViewController.cs</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<InterfaceDefinition Include="MainStoryboard.storyboard" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
<ItemGroup>
|
||||
<ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Contents.json" />
|
||||
<ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon.png" />
|
||||
<ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon%402x.png" />
|
||||
<ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon-60%402x.png" />
|
||||
<ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon-Small.png" />
|
||||
<ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon-Small%402x.png" />
|
||||
<ImageAsset Include="Resources\Images.xcassets\AppIcons.appiconset\Icon-Small-40%402x.png" />
|
||||
<ImageAsset Include="Resources\Images.xcassets\LaunchImage.launchimage\Contents.json" />
|
||||
<ImageAsset Include="Resources\Images.xcassets\LaunchImage.launchimage\Default.png" />
|
||||
<ImageAsset Include="Resources\Images.xcassets\LaunchImage.launchimage\Default%402x.png" />
|
||||
<ImageAsset Include="Resources\Images.xcassets\LaunchImage.launchimage\Default-568h%402x.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ITunesArtwork Include="iTunesArtwork" />
|
||||
<ITunesArtwork Include="iTunesArtwork%402x" />
|
||||
</ItemGroup>
|
||||
</Project>
|
После Ширина: | Высота: | Размер: 106 KiB |
После Ширина: | Высота: | Размер: 273 KiB |