C# 在同一视图控制器中添加集合视图和表视图-Xamarin iOS

C# 在同一视图控制器中添加集合视图和表视图-Xamarin iOS,c#,ios,xamarin,tableview,collectionview,C#,Ios,Xamarin,Tableview,Collectionview,我正在创建一个iPAD应用程序。我需要在同一个视图控制器中有一个UI集合视图和一个表视图。(屏幕分为70%集合视图和30%表格视图 让我这样做的最佳策略是什么 PS:我的要求不允许我使用分割视图 公共部分类POSScreen:UIViewController { UIViewController主控制器 UIViewController SecondaryController; UIView MainView; UIView SecondaryView; /*

我正在创建一个iPAD应用程序。我需要在同一个视图控制器中有一个UI集合视图和一个表视图。(屏幕分为70%集合视图和30%表格视图

让我这样做的最佳策略是什么

PS:我的要求不允许我使用分割视图

公共部分类POSScreen:UIViewController { UIViewController主控制器

    UIViewController SecondaryController;

    UIView MainView;
    UIView SecondaryView;

    /* The Widths */
    nfloat leftSide;
    nfloat rightSide;

    public POSScreen () : base ("POSScreen", null)
    {



    }

    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 ();

        try {
            // Perform any additional setup after loading the view, typically from a nib.
            leftSide = ((nfloat.Parse("65") / nfloat.Parse("100")) * nfloat.Parse( View.Frame.Width.ToString()));
            rightSide = ((nfloat.Parse("35") / nfloat.Parse("100")) * View.Frame.Width);

            MainController = new CategoriesProductsSimpleCollectionViewController();
            SecondaryController = new RightSideItemDetail ();

            (MainController as IViewController).SetCollectionViewFrame (new CoreGraphics.CGRect (0, 40, leftSide, View.Frame.Height));
            (SecondaryController as IViewController).SetCollectionViewFrame (new CoreGraphics.CGRect (View.Frame.Width, 40, rightSide, View.Frame.Height));


            this.Add (this.MainController.View);
            this.Add (this.SecondaryController.View);
        } catch (Exception ex) {
            Console.WriteLine (ex.Message);
        }



    }
}
谢谢

1)创建控制器

public SomeViewController(UIColor color, CGRect frame) : base("SomeViewController", null)
{
     this.color = color;
     this.frame = frame;
}

public override void ViewDidLoad()
{
     base.ViewDidLoad();

     this.View.BackgroundColor = color;
     this.View.Frame = frame;
}
2) 在需要子控制器的控制器中:

var MainController = new SomeViewController(UIColor.Black, new CGRect(0, 0, 100, 500));
var SecondaryController = new SomeViewController(UIColor.Green, new CGRect(150, 0, 100, 500));

this.AddChildViewController(MainController);
this.AddChildViewController(SecondaryController);
this.Add(this.MainController.View);
this.Add(this.SecondaryController.View);
我创建的CGRect只是一个示例
UIScreen.MainScreen.Bounds;

您的需求是否明确规定“不要使用UISplitViewController”或者您对UISplitViewController有一些问题?您好,我需要在我的应用程序中有一个导航控制器,因为在UI中,拆分视图需要是应用程序的根视图控制器,因此不能有拆分视图。是的,我知道主视图和详细视图可以有它们的导航栏项。我确实实现了UI拆分视图,但我走到了死胡同。老实说,我不明白问题出在哪里。如果你需要将UICollectionView和UITableView放在一起,只需这样做并计算它们的帧。仅此而已。帧指定视图边框的X/Y,你可以将这两个视图放在一起。是的,我得出了相同的结论-请参阅更新的代码我是新的ios开发所有是否需要向viewController添加更多viewController?如果不需要,则只需添加视图(UITableView,UICollectionView)而不是viewController(UITableViewController,UICollectionViewController)。