using System; using System.Collections.Generic; using System.Linq; using MonoTouch.Foundation; using MonoTouch.UIKit; using System.Drawing; using MonoTouch.CoreGraphics; namespace delete201205172 { [Register ("AppDelegate")] public partial class AppDelegate : UIApplicationDelegate { UIWindow window; UIViewController _rootCtrl; public override bool FinishedLaunching (UIApplication app, NSDictionary options) { window = new UIWindow (UIScreen.MainScreen.Bounds); _rootCtrl = new MyUIViewController (); window.RootViewController = _rootCtrl; window.MakeKeyAndVisible (); return true; } } public class MyUIViewController : UIViewController { public override void ViewDidLoad () { base.ViewDidLoad (); RectangleF rect = new RectangleF (0, 0, this.View.Bounds.Width/2f, this.View.Bounds.Height); this.View.AddSubview ( new View1 (rect)); rect = new RectangleF (this.View.Bounds.Width/2f, 0, this.View.Bounds.Width/2f, this.View.Bounds.Height); this.View.AddSubview ( new View1 (rect)); this.View.BackgroundColor = UIColor.Green; } } public class View1 : UITableView { public View1 (RectangleF rect) : base (rect, UITableViewStyle.Grouped) { this.Source = new MyDataSource (); } public override void TouchesBegan (NSSet touches, UIEvent evt) { base.TouchesBegan (touches, evt); Console.WriteLine ("View1 TouchesBegan"); } private class MyDataSource : UITableViewSource { #region implemented abstract members of MonoTouch.UIKit.UITableViewDataSource public override int RowsInSection (UITableView tableView, int section) { return 3; } public override UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath) { UITableViewCell cell = tableView.DequeueReusableCell ("MyCellKey"); if (cell == null) { cell = new MyUITableViewCell (); } cell.TextLabel.Text = "Hello"; return cell; } #endregion } } public class MyUITableViewCell : UITableViewCell { public MyUITableViewCell () : base (UITableViewCellStyle.Default, "MyCellKey") { } public override void TouchesBegan (NSSet touches, UIEvent evt) { base.TouchesBegan (touches, evt); Console.WriteLine ("View2 TouchesBegan"); } } }