Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I am not completely sure what you wanted to do. I took my best guess and created a sample with two solutions. One solution per tab. The first uses the built-in split view controller. I have read several places the UISplitViewController must be the root of the application. I have broke that rule by adding it as a child of the tab control.</p> <p>The second creates a custom version of a split control. </p> <pre class="lang-cs prettyprint-override"><code>using System; using System.Collections.Generic; using MonoTouch.Foundation; using MonoTouch.UIKit; using System.Drawing; namespace delete04223 { [Register ("AppDelegate")] public partial class AppDelegate : UIApplicationDelegate { // class-level declarations UIWindow window; UITabBarController tabBarController; public override bool FinishedLaunching (UIApplication app, NSDictionary options) { // create a new window instance based on the screen size window = new UIWindow (UIScreen.MainScreen.Bounds); var viewController1 = new MyUISplitViewController (); var viewController2 = new MyUISplitViewController2 (); tabBarController = new UITabBarController (); tabBarController.ViewControllers = new UIViewController [] { viewController1, viewController2, }; window.RootViewController = tabBarController; // make the window visible window.MakeKeyAndVisible (); return true; } } public class MyUISplitViewController : UISplitViewController { public MyUISplitViewController () { this.Title = "Native Split View"; } public override void ViewDidLoad () { base.ViewDidLoad (); var viewController1 = new LeftViewController (); var viewController2 = new DummyViewController ("Pane 1", "Pane 1"); this.ViewControllers = new UIViewController [] {viewController1, viewController2}; this.WeakDelegate = viewController2; } public override bool ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientation toInterfaceOrientation) { return true; } } public class MyUISplitViewController2 : UIViewController { public MyUISplitViewController2 () { this.Title = "Custom Split View"; } public override void ViewDidLoad () { base.ViewDidLoad (); var viewController1 = new LeftViewController (); var viewController2 = new DummyViewController ("Pane 1", "Pane 1"); this.AddChildViewController (viewController1); this.AddChildViewController (viewController2); this.View.AddSubview (viewController1.View); this.View.AddSubview (viewController2.View); } public override void ViewDidLayoutSubviews () { base.ViewDidLayoutSubviews (); RectangleF lRect = this.View.Frame; RectangleF rRect = lRect; lRect.Width = .3f * lRect.Width; rRect.X = lRect.Width + 1; rRect.Width = (.7f * rRect.Width)-1; this.View.Subviews[0].Frame = lRect; this.View.Subviews[1].Frame = rRect; } public override bool ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientation toInterfaceOrientation) { return true; } } public class LeftViewController : UINavigationController { public LeftViewController () { } public override void ViewDidLoad () { base.ViewDidLoad (); MyUITableViewController table = new MyUITableViewController (this); this.PushViewController (table, false); } public override bool ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientation toInterfaceOrientation) { return true; } public override UIViewController PopViewControllerAnimated (bool animated) { return base.PopViewControllerAnimated (true); } } public class DummyViewController : UIViewController { string _myLabelText = ""; UIToolbar _toolbar; public DummyViewController (string viewName, string labelText) { this.Title = viewName; this._myLabelText = labelText; this.View.BackgroundColor = UIColor.White; } public override bool ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientation toInterfaceOrientation) { return true; } public override void ViewDidLoad () { base.ViewDidLoad (); float center = this.View.Frame.Width / 2f; UILabel label = new UILabel (new RectangleF (center - 50, 100, 100, 40)); label.Text = this._myLabelText; label.TextAlignment = UITextAlignment.Center; label.AutoresizingMask = UIViewAutoresizing.FlexibleMargins; RectangleF rect = this.View.Frame; rect.Y = 0; rect.Height = 44; _toolbar = new UIToolbar (rect); _toolbar.AutoresizingMask = UIViewAutoresizing.FlexibleWidth; this.View.AddSubview (label); this.View.AddSubview (_toolbar); } [Export("splitViewController:willHideViewController:withBarButtonItem:forPopoverController:")] public void WillHideViewController (UISplitViewController svc, UIViewController vc, UIBarButtonItem barButtonItem, UIPopoverController pc) { barButtonItem.Title = "Menu"; var items = new List&lt;UIBarButtonItem&gt; (); items.Add (barButtonItem); if (_toolbar.Items != null) items.AddRange (_toolbar.Items); _toolbar.SetItems (items.ToArray (), true); //popoverController = pc; } [Export("splitViewController:willShowViewController:invalidatingBarButtonItem:")] public void WillShowViewController (UISplitViewController svc, UIViewController vc, UIBarButtonItem button) { // Called when the view is shown again in the split view, invalidating the button and popover controller. var items = new List&lt;UIBarButtonItem&gt; (_toolbar.Items); items.RemoveAt (0); _toolbar.SetItems (items.ToArray (), true); //popoverController = null; } } internal class MyUITableViewController : UITableViewController { static NSString kCellIdentifier = new NSString ("MyIdentifier"); LeftViewController _parent; public MyUITableViewController (LeftViewController parent) : base (UITableViewStyle.Plain) { this.TableView.WeakDelegate = this; this.TableView.WeakDataSource = this; this._parent = parent; } [Export ("tableView:numberOfRowsInSection:")] public int RowsInSection (UITableView tableView, int section) { if (section == 0) return 2; return 3; } [Export ("tableView:cellForRowAtIndexPath:")] public UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath) { var cell = tableView.DequeueReusableCell (kCellIdentifier); if (cell == null) { cell = new UITableViewCell (UITableViewCellStyle.Default, kCellIdentifier); } cell.TextLabel.Text = GetRowName (indexPath); return cell; } private string GetRowName (NSIndexPath indexPath) { string ret; if (indexPath.Section == 0) { ret = indexPath.Row == 0 ? "Row A" : "Row B"; } else { ret = indexPath.Row == 0 ? "Row D" : indexPath.Row == 1 ? "Row E" : "Row F"; } return ret; } [Export ("numberOfSectionsInTableView:")] public int NumberOfSections (UITableView tableView) { return 2; } [Export ("tableView:titleForHeaderInSection:")] public string TitleForHeader (UITableView tableView, int section) { if (section == 0) return "One"; return "Two"; } [Export ("tableView:didSelectRowAtIndexPath:")] public virtual void RowSelected (UITableView tableView, NSIndexPath indexPath) { Console.WriteLine("Item Selected: Section={0}, Row={1}",indexPath.Section, indexPath.Row); this._parent.PushViewController (new MySubUITableViewController (), true); } public override bool ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientation toInterfaceOrientation) { return true; } } internal class MySubUITableViewController : UITableViewController { static NSString kCellIdentifier = new NSString ("MyIdentifier"); static string [] _names = new string [] {"One", "Two", "Three", "Four", "Five"}; public MySubUITableViewController () : base (UITableViewStyle.Plain) { this.TableView.WeakDelegate = this; this.TableView.WeakDataSource = this; } [Export ("tableView:numberOfRowsInSection:")] public int RowsInSection (UITableView tableView, int section) { return 5; } [Export ("tableView:didSelectRowAtIndexPath:")] public virtual void RowSelected (UITableView tableView, NSIndexPath indexPath) { Console.WriteLine("Item Selected: Section={0}, Row={1}",indexPath.Section, indexPath.Row); } [Export ("tableView:cellForRowAtIndexPath:")] public UITableViewCell GetCell (UITableView tableView, NSIndexPath indexPath) { var cell = tableView.DequeueReusableCell (kCellIdentifier); if (cell == null) { cell = new UITableViewCell (UITableViewCellStyle.Default, kCellIdentifier); } cell.TextLabel.Text = _names[indexPath.Row]; return cell; } public override bool ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientation toInterfaceOrientation) { return true; } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload