How to add dialog view manager as a subtitle in UIView or vice versa?

I browsed the website for a while, looking for any resources on this topic and came up with nothing that solves my dilemma.

I have a dialog box controller, and its root just displays a list of strings similar to how the scrollable scroll view is laid out on the iPhone. I need a preview located at the top of the screen and a scrollable DVC below it. I need the top view to always be displayed while the user can scroll the root element, because the top view will contain statistics.

I tried adding a subview, but it just overlaps the dvc below it, and I could not find a way to add dvc as a subview in the UIView.

Any help would be greatly appreciated.

+4
source share
1 answer

This requires one root view controller, which hosts two subview controllers. One view contains statistics at the top of the window. The lower unit contains a navigation controller that contains a dialog box.

using System; using System.Collections.Generic; using System.Linq; using MonoTouch.Foundation; using MonoTouch.UIKit; using MonoTouch.Dialog; using System.Drawing; namespace delete201205203 { [Register ("AppDelegate")] public partial class AppDelegate : UIApplicationDelegate { UIWindow window; MyUIViewController _mvc; public override bool FinishedLaunching (UIApplication app, NSDictionary options) { window = new UIWindow (UIScreen.MainScreen.Bounds); _mvc = new MyUIViewController (); window.RootViewController = _mvc; window.MakeKeyAndVisible (); return true; } } public class MyUIViewController : UIViewController { MyDialogViewController _dvc; UINavigationController _nav; StatisticsViewController _statistics; public override void ViewDidLoad () { base.ViewDidLoad (); var root = new RootElement ("Root") { new Section ("Section") { new EntryElement ("caption", "placeholder", ""), new RootElement ("Root 2") { new Section ("Section") { new EntryElement ("caption", "placeholder", ""), new StringElement ("Back", () => { _nav.PopViewControllerAnimated (true); }) } } } }; _dvc = new MyDialogViewController (root); _nav = new UINavigationController (_dvc); _nav.SetNavigationBarHidden (true, false); _nav.View.Frame = new RectangleF (0, 70f, this.View.Bounds.Width, this.View.Bounds.Height -70f); _statistics = new StatisticsViewController (); _statistics.View.Frame = new RectangleF (0, 0, this.View.Bounds.Width, 70f); this.AddChildViewController (_nav); this.View.AddSubview (_nav.View); this.AddChildViewController (_statistics); this.View.AddSubview (_statistics.View); } public override void ViewWillLayoutSubviews () { base.ViewWillLayoutSubviews (); _nav.View.Frame = new RectangleF (0, 70f, this.View.Bounds.Width, this.View.Bounds.Height -70f); _statistics.View.Frame = new RectangleF (0, 0, this.View.Bounds.Width, 70f); } public override bool ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientation toInterfaceOrientation) { return true; } } public class StatisticsViewController : UIViewController { UILabel _label; public override void ViewDidLoad () { base.ViewDidLoad (); this.View.BackgroundColor = UIColor.White; _label = new UILabel (new RectangleF (this.View.Bounds.Width * .5f - 50f, this.View.Bounds.Height * .5f -10f, 100f, 20f)); _label.AutoresizingMask = UIViewAutoresizing.FlexibleMargins; _label.Text = "statistics"; this.View.AddSubview (_label); } public override bool ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientation toInterfaceOrientation) { return true; } } // This overrde is needed to ensure the pop view animation // works correctly in landscape mode public class MyDialogViewController : DialogViewController { public MyDialogViewController (RootElement root) : base (root) {} public override bool ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientation toInterfaceOrientation) { return true; } } } 
+10
source

Source: https://habr.com/ru/post/1413072/


All Articles