【问题标题】:Finding the location of a UITabBarItem in Monotouch Xamarin.iOS在 Monotouch Xamarin.iOS 中查找 UITabBarItem 的位置
【发布时间】:2013-06-20 09:14:25
【问题描述】:

我正在尝试从 UITabBar 实现我自己的弹出菜单。 我的应用程序允许用户指定在标签栏上显示哪些菜单,我不喜欢 iOS 在标签栏项目很多时使用的默认“更多”按钮,所以我想创建一些标签栏项目是“子菜单”,可以提供更多按钮的菜单。我希望它从 tabbaritem 本身弹出,并且每个用户的选项卡顺序可能不一样。 到目前为止,我可以找到用户选择的 tabbaritem,但接下来我需要知道它的位置,以便我可以从该位置为弹出菜单设置动画。

有谁知道我如何才能找到所选 tabbaritem 的框架或位置?

【问题讨论】:

    标签: c# ios xamarin.ios uitabbarcontroller xamarin


    【解决方案1】:

    您可以遍历 UITabBar 的子视图并仅获取属于 UITabBarButton 类的那些子视图。然后你得到你感兴趣的子视图的框架。

    List<RectangleF> tabBarButtonFrames = new List<RectangleF>();
    
    foreach (var view in this.tabBarController.TabBar.Subviews) {
        if (view.ToString().Contains("UITabBarButton")) {
            tabBarButtonFrames.Add(view.Frame);
        }
    
        Console.WriteLine(view.ToString() + "\t" + view.Frame.ToString());
    }
    

    注意:This link 包含更多从 poupou 获取 Objective-C 类名的方法

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-06-20
      • 1970-01-01
      • 1970-01-01
      • 2012-04-28
      • 1970-01-01
      • 1970-01-01
      • 2012-04-06
      • 1970-01-01
      相关资源
      最近更新 更多