(includes swipe-to-delete and edit-mode)
This commit is contained in:
ConceptDev 2012-03-29 12:47:27 +11:00
Родитель 5117f27192
Коммит cf67eecbf8
32 изменённых файлов: 986 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8" ?>
<SampleMetadata>
<ID>cb0481204-f206-472e-9426-8e7a027974cf</ID>
<IsFullApplication>false</IsFullApplication>
<Level>Intermediate</Level>
<Tags>User Interface</Tags>
</SampleMetadata>

9
TableEditing/README.md Normal file
Просмотреть файл

@ -0,0 +1,9 @@
Table Editing
=============
This is a very simple sample that demonstrates how to implement swipe-to-delete and 'edit mode' in UITableView with MonoTouch.
Authors
-------
Bryan Costanich

Двоичные данные
TableEditing/Screenshots/EditModeInsert.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 51 KiB

Двоичные данные
TableEditing/Screenshots/EditModeMove.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 51 KiB

Двоичные данные
TableEditing/Screenshots/EditModeTrash.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 51 KiB

Двоичные данные
TableEditing/Screenshots/NoEditing.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 45 KiB

Двоичные данные
TableEditing/Screenshots/SwipeToDelete.png Normal file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 46 KiB

Просмотреть файл

@ -0,0 +1,28 @@
Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TableEditing", "TableEditing/TableEditing.csproj", "{15D8E98D-D803-4CCC-906F-0960D31DD333}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|iPhoneSimulator = Debug|iPhoneSimulator
Release|iPhoneSimulator = Release|iPhoneSimulator
Debug|iPhone = Debug|iPhone
Release|iPhone = Release|iPhone
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{15D8E98D-D803-4CCC-906F-0960D31DD333}.Debug|iPhone.ActiveCfg = Debug|iPhone
{15D8E98D-D803-4CCC-906F-0960D31DD333}.Debug|iPhone.Build.0 = Debug|iPhone
{15D8E98D-D803-4CCC-906F-0960D31DD333}.Debug|iPhoneSimulator.ActiveCfg = Debug|iPhoneSimulator
{15D8E98D-D803-4CCC-906F-0960D31DD333}.Debug|iPhoneSimulator.Build.0 = Debug|iPhoneSimulator
{15D8E98D-D803-4CCC-906F-0960D31DD333}.Release|iPhone.ActiveCfg = Release|iPhone
{15D8E98D-D803-4CCC-906F-0960D31DD333}.Release|iPhone.Build.0 = Release|iPhone
{15D8E98D-D803-4CCC-906F-0960D31DD333}.Release|iPhoneSimulator.ActiveCfg = Release|iPhoneSimulator
{15D8E98D-D803-4CCC-906F-0960D31DD333}.Release|iPhoneSimulator.Build.0 = Release|iPhoneSimulator
EndGlobalSection
GlobalSection(MonoDevelopProperties) = preSolution
StartupItem = TableEditing.csproj
description = Editable UITableView sample
version = 1.0
EndGlobalSection
EndGlobal

Просмотреть файл

@ -0,0 +1,47 @@
using System;
using MonoTouch.UIKit;
using MonoTouch.Foundation;
namespace TableEditing {
[Register("AppDelegate")]
public class AppDelegate : UIApplicationDelegate {
#region -= main =-
public static void Main (string[] args)
{
try {
UIApplication.Main (args, null, "AppDelegate");
} catch (Exception e) {
Console.WriteLine (e.ToString ());
}
}
#endregion
#region -= declarations and properties =-
protected UIWindow window;
protected TableEditing.Screens.HomeScreen iPhoneHome;
#endregion
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
//---- create our window
window = new UIWindow (UIScreen.MainScreen.Bounds);
window.MakeKeyAndVisible ();
//---- create the home screen
iPhoneHome = new TableEditing.Screens.HomeScreen();
iPhoneHome.View.Frame = new System.Drawing.RectangleF(0
, UIApplication.SharedApplication.StatusBarFrame.Height
, UIScreen.MainScreen.ApplicationFrame.Width
, UIScreen.MainScreen.ApplicationFrame.Height);
window.AddSubview (this.iPhoneHome.View);
return true;
}
}
}

Просмотреть файл

@ -0,0 +1,33 @@
using System;
using MonoTouch.UIKit;
namespace TableEditing.Code {
/// <summary>
/// Represents our item in the table
/// </summary>
public class TableItem
{
public string Heading { get; set; }
public string SubHeading { get; set; }
public string ImageName { get; set; }
public UITableViewCellStyle CellStyle {
get { return cellStyle; }
set { cellStyle = value; }
}
UITableViewCellStyle cellStyle = UITableViewCellStyle.Default;
public UITableViewCellAccessory CellAccessory {
get { return cellAccessory; }
set { cellAccessory = value; }
}
UITableViewCellAccessory cellAccessory = UITableViewCellAccessory.None;
public TableItem () { }
public TableItem (string heading)
{ this.Heading = heading; }
}
}

Просмотреть файл

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using MonoTouch.UIKit;
namespace TableEditing.Code {
/// <summary>
/// A group that contains table items
/// </summary>
public class TableItemGroup {
public string Name { get; set; }
public string Footer { get; set; }
public List<TableItem> Items
{
get { return items; }
set { items = value; }
}
List<TableItem> items = new List<TableItem> ();
}
}

Просмотреть файл

@ -0,0 +1,242 @@
using System;
using System.Collections.Generic;
using System.IO;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
namespace TableEditing.Code {
/// <summary>
/// Combined DataSource and Delegate for our UITableView
/// </summary>
public class TableSource : UITableViewSource {
//---- declare vars
List<TableItemGroup> tableItems;
string cellIdentifier = "TableCell";
public TableSource (List<TableItemGroup> items)
{
this.tableItems = items;
}
#region -= data binding/display methods =-
/// <summary>
/// Called by the TableView to determine how many sections(groups) there are.
/// </summary>
public override int NumberOfSections (UITableView tableView)
{
return tableItems.Count;
}
/// <summary>
/// Called by the TableView to determine how many cells to create for that particular section.
/// </summary>
public override int RowsInSection (UITableView tableview, int section)
{
return tableItems[section].Items.Count;
}
/// <summary>
/// Called by the TableView to retrieve the header text for the particular section(group)
/// </summary>
public override string TitleForHeader (UITableView tableView, int section)
{
return tableItems[section].Name;
}
/// <summary>
/// Called by the TableView to retrieve the footer text for the particular section(group)
/// </summary>
public override string TitleForFooter (UITableView tableView, int section)
{
return tableItems[section].Footer;
}
#endregion
#region -= user interaction methods =-
public override void RowSelected (UITableView tableView, NSIndexPath indexPath)
{
new UIAlertView("Row Selected"
, tableItems[indexPath.Section].Items[indexPath.Row].Heading, null, "OK", null).Show();
}
public override void RowDeselected (UITableView tableView, NSIndexPath indexPath)
{
Console.WriteLine("Row " + indexPath.Row.ToString() + " deselected");
}
public override void AccessoryButtonTapped (UITableView tableView, NSIndexPath indexPath)
{
Console.WriteLine("Accessory for Section, " + indexPath.Section.ToString() + " and Row, " + indexPath.Row.ToString() + " tapped");
}
#endregion
#region -= editing methods =-
/// <summary>
/// Called by the table view to determine whether or not the row is editable
/// </summary>
public override bool CanEditRow (UITableView tableView, NSIndexPath indexPath)
{
return true;
}
/// <summary>
/// Called by the table view to determine whether or not the row is moveable
/// </summary>
public override bool CanMoveRow (UITableView tableView, NSIndexPath indexPath)
{
return true;
}
/// <summary>
/// Called by the table view to determine whether the editing control should be an insert
/// or a delete.
/// </summary>
public override UITableViewCellEditingStyle EditingStyleForRow (UITableView tableView, NSIndexPath indexPath)
{
// WARNING: SPECIAL HANDLING HERE FOR THE SECOND ROW
// ALSO MEANS SWIPE-TO-DELETE DOESN'T WORK ON THAT ROW
if (indexPath.Section == 0 && indexPath.Row == 1)
{
return UITableViewCellEditingStyle.Insert;
} else
{
return UITableViewCellEditingStyle.Delete;
}
}
/// <summary>
/// Custom text for delete button
/// </summary>
public override string TitleForDeleteConfirmation (UITableView tableView, NSIndexPath indexPath)
{
return "Trash"; // instead of Delete
}
/// <summary>
/// Should be called CommitEditingAction or something, is called when a user initiates a specific editing event
/// </summary>
public override void CommitEditingStyle (UITableView tableView, UITableViewCellEditingStyle editingStyle, MonoTouch.Foundation.NSIndexPath indexPath)
{
switch (editingStyle)
{
case UITableViewCellEditingStyle.Delete:
//---- remove the item from the underlying data source
tableItems[indexPath.Section].Items.RemoveAt (indexPath.Row);
//---- delete the row from the table
tableView.DeleteRows (new NSIndexPath[] { indexPath }, UITableViewRowAnimation.Fade);
break;
case UITableViewCellEditingStyle.Insert:
//---- create a new item and add it to our underlying data
tableItems[indexPath.Section].Items.Insert (indexPath.Row, new TableItem ("(inserted)"));
//---- insert a new row in the table
tableView.InsertRows (new NSIndexPath[] { indexPath }, UITableViewRowAnimation.Fade);
break;
case UITableViewCellEditingStyle.None:
Console.WriteLine ("CommitEditingStyle:None called");
break;
}
}
/// <summary>
/// called by the table view when a row is moved.
/// </summary>
public override void MoveRow (UITableView tableView, NSIndexPath sourceIndexPath, NSIndexPath destinationIndexPath)
{
//---- get a reference to the item
var item = tableItems[sourceIndexPath.Section].Items[sourceIndexPath.Row];
int deleteAt = sourceIndexPath.Row;
//---- if we're moving within the same section, and we're inserting it before
if ((sourceIndexPath.Section == destinationIndexPath.Section) && (destinationIndexPath.Row < sourceIndexPath.Row))
{
//---- add one to where we delete, because we're increasing the index by inserting
deleteAt = sourceIndexPath.Row + 1;
}
//---- copy the item to the new location
tableItems[destinationIndexPath.Section].Items.Insert (destinationIndexPath.Row, item);
//---- remove from the old
tableItems[sourceIndexPath.Section].Items.RemoveAt (deleteAt);
}
/// <summary>
/// Called manually when the table goes into edit mode
/// </summary>
public void WillBeginTableEditing (UITableView tableView)
{
//---- start animations
tableView.BeginUpdates ();
//---- insert a new row in the table
tableView.InsertRows (new NSIndexPath[] { NSIndexPath.FromRowSection (1, 1) }, UITableViewRowAnimation.Fade);
//---- create a new item and add it to our underlying data
tableItems[1].Items.Insert (1, new TableItem ());
//---- end animations
tableView.EndUpdates ();
}
/// <summary>
/// Called manually when the table leaves edit mode
/// </summary>
public void DidFinishTableEditing (UITableView tableView)
{
//---- start animations
tableView.BeginUpdates ();
//---- remove our row from the underlying data
tableItems[1].Items.RemoveAt (1);
//---- remove the row from the table
tableView.DeleteRows (new NSIndexPath[] { NSIndexPath.FromRowSection (1, 1) }, UITableViewRowAnimation.Fade);
//---- finish animations
tableView.EndUpdates ();
}
#endregion
/// <summary>
/// Called by the TableView to get the actual UITableViewCell to render for the particular section and row
/// </summary>
public override UITableViewCell GetCell (UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath)
{
//---- declare vars
UITableViewCell cell = tableView.DequeueReusableCell (cellIdentifier);
TableItem item = tableItems[indexPath.Section].Items[indexPath.Row];
//---- if there are no cells to reuse, create a new one
if (cell == null)
cell = new UITableViewCell (item.CellStyle, cellIdentifier);
//---- set the item text
cell.TextLabel.Text = tableItems[indexPath.Section].Items[indexPath.Row].Heading;
//---- if it's a cell style that supports a subheading, set it
if(item.CellStyle == UITableViewCellStyle.Subtitle
|| item.CellStyle == UITableViewCellStyle.Value1
|| item.CellStyle == UITableViewCellStyle.Value2)
{ cell.DetailTextLabel.Text = item.SubHeading; }
//---- if the item has a valid image, and it's not the contact style (doesn't support images)
if(!string.IsNullOrEmpty(item.ImageName) && item.CellStyle != UITableViewCellStyle.Value2)
{
if(File.Exists(item.ImageName))
{ cell.ImageView.Image = UIImage.FromBundle(item.ImageName); }
}
//---- set the accessory
cell.Accessory = item.CellAccessory;
return cell;
}
}
}

Двоичные данные
TableEditing/TableEditing/Images/Beach.png Executable file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 5.8 KiB

Двоичные данные
TableEditing/TableEditing/Images/Beach@2x.png Executable file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 14 KiB

Двоичные данные
TableEditing/TableEditing/Images/Icons/114_icon.png Executable file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 20 KiB

Двоичные данные
TableEditing/TableEditing/Images/Icons/29_icon.png Executable file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 2.9 KiB

Двоичные данные
TableEditing/TableEditing/Images/Icons/50_icon.png Executable file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 5.8 KiB

Двоичные данные
TableEditing/TableEditing/Images/Icons/512_icon.png Executable file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 318 KiB

Двоичные данные
TableEditing/TableEditing/Images/Icons/57_icon.png Executable file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 7.1 KiB

Двоичные данные
TableEditing/TableEditing/Images/Icons/58_icon.png Executable file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 7.3 KiB

Двоичные данные
TableEditing/TableEditing/Images/Icons/72_icon.png Executable file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 10 KiB

Двоичные данные
TableEditing/TableEditing/Images/Plants.png Executable file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 7.2 KiB

Двоичные данные
TableEditing/TableEditing/Images/Plants@2x.png Executable file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 21 KiB

Двоичные данные
TableEditing/TableEditing/Images/Seeds.png Executable file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 6.9 KiB

Двоичные данные
TableEditing/TableEditing/Images/Seeds@2x.png Executable file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 18 KiB

Двоичные данные
TableEditing/TableEditing/Images/Shanghai.png Executable file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 4.2 KiB

Двоичные данные
TableEditing/TableEditing/Images/Shanghai@2x.png Executable file

Двоичный файл не отображается.

После

Ширина:  |  Высота:  |  Размер: 13 KiB

Просмотреть файл

@ -0,0 +1,32 @@
<?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>Table Editing</string>
<key>CFBundleIconFiles</key>
<array>
<string>Images/Icons/57_icon.png</string>
<string>Images/Icons/114_icon.png</string>
<string>Images/Icons/72_icon.png</string>
<string>Images/Icons/29_icon.png</string>
<string>Images/Icons/58_icon.png</string>
<string>Images/Icons/50_icon.png</string>
<string>Images/Icons/512_icon.png</string>
</array>
<key>CFBundleIdentifier</key>
<string>com.xamarin.samples.tableediting</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>MinimumOSVersion</key>
<string>5.0</string>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
</array>
</dict>
</plist>

Просмотреть файл

@ -0,0 +1,326 @@
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="7.10">
<data>
<int key="IBDocument.SystemTarget">768</int>
<string key="IBDocument.SystemVersion">11D50</string>
<string key="IBDocument.InterfaceBuilderVersion">2182</string>
<string key="IBDocument.AppKitVersion">1138.32</string>
<string key="IBDocument.HIToolboxVersion">568.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="NS.object.0">1179</string>
</object>
<object class="NSArray" key="IBDocument.IntegratedClassDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>IBUIBarButtonItem</string>
<string>IBUIToolbar</string>
<string>IBUITableView</string>
<string>IBUIView</string>
<string>IBProxyObject</string>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</object>
<object class="NSMutableDictionary" key="IBDocument.Metadata">
<string key="NS.key.0">PluginDependencyRecalculationVersion</string>
<integer value="1" key="NS.object.0"/>
</object>
<object class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBProxyObject" id="372490531">
<string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
<object class="IBProxyObject" id="711762367">
<string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
<object class="IBUIView" id="191373211">
<reference key="NSNextResponder"/>
<int key="NSvFlags">292</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBUITableView" id="916865684">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">274</int>
<string key="NSFrameSize">{320, 416}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="147939561"/>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MQA</bytes>
</object>
<bool key="IBUIClipsSubviews">YES</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<bool key="IBUIAlwaysBounceVertical">YES</bool>
<int key="IBUISeparatorStyle">1</int>
<int key="IBUISectionIndexMinimumDisplayRowCount">0</int>
<bool key="IBUIShowsSelectionImmediatelyOnTouchBegin">YES</bool>
<float key="IBUIRowHeight">44</float>
<float key="IBUISectionHeaderHeight">22</float>
<float key="IBUISectionFooterHeight">22</float>
</object>
<object class="IBUIToolbar" id="147939561">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">266</int>
<string key="NSFrame">{{0, 416}, {320, 44}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView"/>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<object class="NSMutableArray" key="IBUIItems">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBUIBarButtonItem" id="617491627">
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<int key="IBUIStyle">1</int>
<reference key="IBUIToolbar" ref="147939561"/>
<int key="IBUISystemItemIdentifier">2</int>
</object>
<object class="IBUIBarButtonItem" id="754076157">
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<reference key="IBUIToolbar" ref="147939561"/>
<int key="IBUISystemItemIdentifier">5</int>
</object>
<object class="IBUIBarButtonItem" id="899044188">
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
<int key="IBUIStyle">1</int>
<reference key="IBUIToolbar" ref="147939561"/>
<int key="IBUISystemItemIdentifier">0</int>
</object>
</object>
</object>
</object>
<string key="NSFrame">{{0, 20}, {320, 460}}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="916865684"/>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MQA</bytes>
<object class="NSColorSpace" key="NSCustomColorSpace">
<int key="NSID">2</int>
</object>
</object>
<object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics"/>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
</object>
<object class="IBObjectContainer" key="IBDocument.Objects">
<object class="NSMutableArray" key="connectionRecords">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">view</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="191373211"/>
</object>
<int key="connectionID">7</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">btnEdit</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="617491627"/>
</object>
<int key="connectionID">11</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">tblMain</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="916865684"/>
</object>
<int key="connectionID">12</int>
</object>
<object class="IBConnectionRecord">
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">btnDone</string>
<reference key="source" ref="372490531"/>
<reference key="destination" ref="899044188"/>
</object>
<int key="connectionID">14</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBObjectRecord">
<int key="objectID">0</int>
<object class="NSArray" key="object" id="0">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<reference key="children" ref="1000"/>
<nil key="parent"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">1</int>
<reference key="object" ref="191373211"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="147939561"/>
<reference ref="916865684"/>
</object>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">-1</int>
<reference key="object" ref="372490531"/>
<reference key="parent" ref="0"/>
<string key="objectName">File's Owner</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-2</int>
<reference key="object" ref="711762367"/>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">8</int>
<reference key="object" ref="147939561"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="617491627"/>
<reference ref="899044188"/>
<reference ref="754076157"/>
</object>
<reference key="parent" ref="191373211"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">9</int>
<reference key="object" ref="617491627"/>
<reference key="parent" ref="147939561"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">10</int>
<reference key="object" ref="916865684"/>
<reference key="parent" ref="191373211"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">13</int>
<reference key="object" ref="899044188"/>
<reference key="parent" ref="147939561"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">15</int>
<reference key="object" ref="754076157"/>
<reference key="parent" ref="147939561"/>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>-1.CustomClassName</string>
<string>-1.IBPluginDependency</string>
<string>-2.CustomClassName</string>
<string>-2.IBPluginDependency</string>
<string>1.IBPluginDependency</string>
<string>10.IBPluginDependency</string>
<string>13.IBPluginDependency</string>
<string>15.IBPluginDependency</string>
<string>8.IBPluginDependency</string>
<string>9.IBPluginDependency</string>
</object>
<object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>HomeScreen</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>UIResponder</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</object>
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference key="dict.sortedKeys" ref="0"/>
<reference key="dict.values" ref="0"/>
</object>
<nil key="activeLocalization"/>
<object class="NSMutableDictionary" key="localizations">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference key="dict.sortedKeys" ref="0"/>
<reference key="dict.values" ref="0"/>
</object>
<nil key="sourceID"/>
<int key="maxID">15</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBPartialClassDescription">
<string key="className">HomeScreen</string>
<string key="superclassName">UIViewController</string>
<object class="NSMutableDictionary" key="outlets">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>btnDone</string>
<string>btnEdit</string>
<string>tblMain</string>
</object>
<object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>UIBarButtonItem</string>
<string>UIBarButtonItem</string>
<string>UITableView</string>
</object>
</object>
<object class="NSMutableDictionary" key="toOneOutletInfosByName">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>btnDone</string>
<string>btnEdit</string>
<string>tblMain</string>
</object>
<object class="NSArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBToOneOutletInfo">
<string key="name">btnDone</string>
<string key="candidateClassName">UIBarButtonItem</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">btnEdit</string>
<string key="candidateClassName">UIBarButtonItem</string>
</object>
<object class="IBToOneOutletInfo">
<string key="name">tblMain</string>
<string key="candidateClassName">UITableView</string>
</object>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/HomeScreen.h</string>
</object>
</object>
</object>
</object>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencies">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS</string>
<integer value="768" key="NS.object.0"/>
</object>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.iPhoneOS</string>
<real value="1296" key="NS.object.0"/>
</object>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3</string>
<integer value="3000" key="NS.object.0"/>
</object>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
<string key="IBCocoaTouchPluginVersion">1179</string>
</data>
</archive>

Просмотреть файл

@ -0,0 +1,84 @@
using System;
using System.Collections.Generic;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
using TableEditing.Code;
namespace TableEditing.Screens {
public partial class HomeScreen : UIViewController {
protected TableSource tableSource;
#region Constructors
// The IntPtr and initWithCoder constructors are required for items that need
// to be able to be created from a xib rather than from managed code
public HomeScreen (IntPtr handle) : base(handle)
{
Initialize ();
}
[Export("initWithCoder:")]
public HomeScreen (NSCoder coder) : base(coder)
{
Initialize ();
}
public HomeScreen () : base("HomeScreen", null)
{
Initialize ();
}
void Initialize ()
{
}
#endregion
public override void ViewDidLoad ()
{
base.ViewDidLoad ();
btnDone.Enabled = false;
CreateTableItems ();
tblMain.Source = tableSource;
//---- toggle the table's editing mode when the edit button is clicked
btnEdit.Clicked += (s, e) => {
tblMain.SetEditing (true, true);
btnEdit.Enabled = false;
btnDone.Enabled = true;
};
btnDone.Clicked += (sender, e) => {
tblMain.SetEditing (false, true);
btnEdit.Enabled = true;
btnDone.Enabled = false;
};
}
/// <summary>
/// Creates a set of table items.
/// </summary>
protected void CreateTableItems ()
{
List<TableItemGroup> tableItems = new List<TableItemGroup> ();
//---- declare vars
TableItemGroup tableGroup;
//---- Section 1
tableGroup = new TableItemGroup() { Name = "Places" };
tableGroup.Items.Add (new TableItem() { ImageName = "Images/Beach.png", Heading = "Fiji", SubHeading = "A nice beach" });
tableGroup.Items.Add (new TableItem() { ImageName = "Images/Shanghai.png", Heading = "Beijing", SubHeading = "AKA Shanghai" });
tableItems.Add (tableGroup);
//---- Section 2
tableGroup = new TableItemGroup() { Name = "Other" };
tableGroup.Items.Add (new TableItem() { ImageName = "Images/Seeds.png", Heading = "Seedlings", SubHeading = "Tiny Plants" });
tableGroup.Items.Add (new TableItem() { ImageName = "Images/Plants.png", Heading = "Plants", SubHeading = "Green plants" });
tableItems.Add (tableGroup);
tableSource = new TableSource(tableItems);
}
}
}

41
TableEditing/TableEditing/Screens/HomeScreen.xib.designer.cs сгенерированный Executable file
Просмотреть файл

@ -0,0 +1,41 @@
// WARNING
//
// 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 TableEditing.Screens
{
[Register ("HomeScreen")]
partial class HomeScreen
{
[Outlet]
MonoTouch.UIKit.UIBarButtonItem btnEdit { get; set; }
[Outlet]
MonoTouch.UIKit.UITableView tblMain { get; set; }
[Outlet]
MonoTouch.UIKit.UIBarButtonItem btnDone { get; set; }
void ReleaseDesignerOutlets ()
{
if (btnEdit != null) {
btnEdit.Dispose ();
btnEdit = null;
}
if (tblMain != null) {
tblMain.Dispose ();
tblMain = null;
}
if (btnDone != null) {
btnDone.Dispose ();
btnDone = null;
}
}
}
}

Просмотреть файл

@ -0,0 +1,116 @@
<?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>9.0.21022</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{15D8E98D-D803-4CCC-906F-0960D31DD333}</ProjectGuid>
<ProjectTypeGuids>{6BC8ED88-2882-458C-8E55-DFD12B67127B};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<OutputType>Exe</OutputType>
<RootNamespace>TableEditing</RootNamespace>
<AssemblyName>Example_EditableTable</AssemblyName>
<ReleaseVersion>1.0</ReleaseVersion>
</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>
<MtouchDebug>true</MtouchDebug>
<ConsolePause>false</ConsolePause>
<MtouchLink>None</MtouchLink>
<MtouchI18n />
<MtouchUseArmv7>false</MtouchUseArmv7>
<MtouchArch>ARMv7</MtouchArch>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhoneSimulator' ">
<DebugType>none</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\iPhoneSimulator\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<MtouchLink>None</MtouchLink>
<MtouchI18n />
<MtouchUseArmv7>false</MtouchUseArmv7>
</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>
<MtouchI18n />
<MtouchUseArmv7>false</MtouchUseArmv7>
<IpaPackageName />
<MtouchArch>ARMv7</MtouchArch>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|iPhone' ">
<DebugType>none</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\iPhone\Release</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
<CodesignKey>iPhone Developer</CodesignKey>
<MtouchI18n />
<MtouchUseArmv7>false</MtouchUseArmv7>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="monotouch" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<Compile Include="AppDelegate.cs" />
<Compile Include="Code\TableItem.cs" />
<Compile Include="Code\TableItemGroup.cs" />
<Compile Include="Code\TableSource.cs" />
<Compile Include="Screens\HomeScreen.xib.cs">
<DependentUpon>HomeScreen.xib</DependentUpon>
</Compile>
<Compile Include="Screens\HomeScreen.xib.designer.cs">
<DependentUpon>HomeScreen.xib</DependentUpon>
</Compile>
</ItemGroup>
<ItemGroup>
<Folder Include="Images\" />
<Folder Include="Images\Icons\" />
<Folder Include="Code\" />
<Folder Include="Screens\" />
</ItemGroup>
<ItemGroup>
<Content Include="Images\Beach.png" />
<Content Include="Images\Beach%402x.png" />
<Content Include="Images\Plants.png" />
<Content Include="Images\Plants%402x.png" />
<Content Include="Images\Seeds.png" />
<Content Include="Images\Seeds%402x.png" />
<Content Include="Images\Shanghai.png" />
<Content Include="Images\Shanghai%402x.png" />
<Content Include="Images\Icons\29_icon.png" />
<Content Include="Images\Icons\50_icon.png" />
<Content Include="Images\Icons\57_icon.png" />
<Content Include="Images\Icons\58_icon.png" />
<Content Include="Images\Icons\72_icon.png" />
<Content Include="Images\Icons\114_icon.png" />
<Content Include="Images\Icons\512_icon.png" />
</ItemGroup>
<ItemGroup>
<None Include="Info.plist" />
</ItemGroup>
<ItemGroup>
<InterfaceDefinition Include="Screens\HomeScreen.xib" xmlns="" />
</ItemGroup>
</Project>