【问题标题】:Monotouch UITabBarController section showing a modal view显示模态视图的 Monotouch UITabBarController 部分
【发布时间】:2012-03-06 02:24:23
【问题描述】:

当我点击我的 UITabBarController 的一部分时,我想显示一个模态视图,或者可能是一个 uipopoverbackgroundview,例如 GroupMe 应用程序中包含的那个。 (图片供参考)。

http://wpuploads.appadvice.com/wp-content/uploads/2011/09/groupme-iphone-app-300x452-199x300.jpg

你知道用单点触控而不是标准加载带有视图控制器的导航控制器的方法吗?

...现在我有一个额外的复杂性,因为我不能使用“在标签栏顶部放置一个装饰按钮”解决方法,因为该选项是我的标签栏中的数字 7,所以它出现在“更多”部分控制...任何帮助将不胜感激。

【问题讨论】:

    标签: xamarin.ios uitabbarcontroller modal-dialog modalviewcontroller


    【解决方案1】:

    我使用弹出框和对话框实现了类似的功能。

    我有一个 barbuttonitem,当按下它时会弹出一个下拉列表,让您在不同的公司之间进行选择。 myPopController 是一个类级别的变量,然后字符串元素内的 lambda 表达式重定向到一个特定的函数。

    代码如下

    void HandleBtnCompanyhandleClicked (object sender, EventArgs e)
        {
    
            if(myPopController != null)
            {
                myPopController.Dismiss(true);
                myPopController.Dispose();
            }
    
            //create the view
            UIView contentView = new UIView();
            contentView.Frame = new RectangleF(new PointF(0,0), new SizeF(320f, 240f));
            //create the view controller
            UIViewController vc = new UIViewController();
            vc.Add(contentView);
            //set the popupcontroller
            myPopController = new UIPopoverController(vc);
            myPopController.PopoverContentSize = new SizeF(320f, 240f);
    
            //Add the elements to the rootelement for the companies
            // TODO: change to a DB read eventually
            RootElement rt = new RootElement(""){
                new Section ("Requests") {
                    new StringElement ("ABC Company",() => {companyTapped("ABC Company");}),
                    new StringElement ("Northwind", () => {companyTapped("Northwind");}),
                    new StringElement ("Initrode", () => {companyTapped("Initrode");}),
                    new StringElement ("Foo Bars Group", () => {companyTapped("Foo Bars Group");}),
                    new StringElement ("Widget Corp", () => {companyTapped("Widget Corp");}),
                }
            };
    
            //create the DVC and add to the popup
            DialogViewController dvc = new DialogViewController(rt);
            contentView.AddSubview(dvc.View);
            myPopController.PresentFromBarButtonItem(btnCompany,UIPopoverArrowDirection.Up,true);
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-02
      • 1970-01-01
      相关资源
      最近更新 更多