【问题标题】:C# Xamarin - Popover segue causes anonymous build errorC# Xamarin - Popover segue 导致匿名构建错误
【发布时间】:2016-05-12 19:01:22
【问题描述】:

首先,有相关的环境细节排除环境因素可能对您有帮助:

Dev PC Environment 
_______________________
Windows 10 Enterprise 64 Bit
Intel Core i7 3.40GHz 16GB RAM 
Visual Studio Professional 2015 Version 14.0.25123.00 Update 2
Xamarin 4.0.3.214 (0dd817c)
Xamarin.iOS 9.6.1.8 (3a25bf1)


Macbook (Agent) Environment - used to build and simulate
______________________
OS X El Capitan Version 10.11.4
Simulator Version 9.3
Xcode Version 7.3 (7D175)

查看所以我无法通过以下问题herehere 以及通常在 Xamarin 文档here 中解决问题。

我在构建时在 Xamarin.iOS 中遇到了这个错误:

1>------ Build started: Project: App5.iOS, Configuration: Debug iPhone ------
1>  Generated session id: 22824a3fd65b76ad8c03fd7694e35be1
1>  Generated build app name: App5iOS
1>  Connecting to Mac server 192.168.1.197...
1>  C:\Program Files (x86)\MSBuild\Xamarin\iOS\Xamarin.iOS.Common.targets(997,3): error : 
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========

我有一个名为 MainViewController 的 ViewController,它是空白的,除了一个名为 MenuButton 的 UIButton,我的 MainViewController.designer.cs 说它被正确地归因于 [Outlet]

CTRL + LEFT CLICKEDMenuButtonMain.storyboard 并正确拖到创建 Segue 的 NavigationDropdownViewController。我将此segue命名为NavigationMenuSegue

Widget 标签中,我设置了以下内容:

如果我从“Adaptive Segue”树中选择“Present As Popover”或从“Deprecated Segue”树中选择“Popover”,则构建操作会遇到上述错误。

奇怪的是,如果我选择“以模式呈现”或“推送”选项,下拉菜单会在单击 MenuButton 时出现 - 尽管位置错误!本质上,我希望它作为一个弹出框切换,插入符号指向菜单按钮(这就是我的要求!)

我想要的只是出现在MenuButton 下方的下拉菜单,其样式与基于汉堡包的 web 菜单的样式非常相似...我担心这不是 Xamarin 的 Bugzilla here 的孤立问题

在 Xcode 中,我可以简单地删除 Views 并使用 .xibs 来轻松地进行 segue - 我似乎并不理解 Xamarin 的设计器。

这是我的 MainViewController.cs

partial class MainViewController : UIViewController
{
    public MainViewController (IntPtr handle) : base (handle)
    {
    }
}

[Register ("MainViewController")]
partial class MainViewController
{
    [Outlet]
    [GeneratedCode ("iOS Designer", "1.0")]
    UIButton MenuButton { get; set; }

    [Outlet]
    [GeneratedCode ("iOS Designer", "1.0")]
    UIView MainView { get; set; }

    void ReleaseDesignerOutlets ()
    {
        if (MenuButton != null) {
            MenuButton.Dispose ();
            MenuButton = null;
        }
        if (MainView != null) {
            MainView.Dispose ();
            MainView = null;
        }
    }
}

NaviagationBarDropdownViewController.cs

   [Register ("NavigationBarDropdownViewController")]
    partial class NavigationBarDropdownViewController
    {
        [Outlet]
        [GeneratedCode ("iOS Designer", "1.0")]
        UIButton LogoutButton { get; set; }

        [Outlet]
        [GeneratedCode ("iOS Designer", "1.0")]
        UIImageView LogoutIcon { get; set; }

        // omitted the other [Outlet]s for the five other buttons in the view for brevity   

        [Outlet]
        [GeneratedCode ("iOS Designer", "1.0")]
        UIView NavigationBarDropdownView { get; set; }

        void ReleaseDesignerOutlets ()
        {
            // omitted for brevity
        }
    }

Popover Segue 构建错误是框架中的错误,还是我在创建非常简单的 Menu -> Dropdown UI 模式时完全走错了路!

感谢您花时间阅读本文并为解决方案做出贡献 - 因为我不能再为此失去头发!

约翰

【问题讨论】:

    标签: c# ios xamarin segue viewcontroller


    【解决方案1】:

    好的,

    我希望这可以帮助其他使用 Xamarin.IOS 设计器遇到此问题的人。

    通过与 Xamarin 开发人员的交谈,我了解到该问题现已在最新的 4.1.x 版本中得到解决(目前在他们的测试版中)。但是,那些宁愿使用稳定构建(即 4.0.x)的人则按照以下步骤解决匿名构建错误:

    首先,选择您希望触发 Popover 的 UI 元素,在我的例子中是 MenuButton。请注意LocalizationID,您可以通过单击设计器中的元素并查看“属性”窗口来找到它。在我的例子中,MenUButton 的 LocalizationID 是 204

    现在单击 Segue 并再次导航到 "Properties" 窗口。从"Segue" 下拉列表中选择"Present As Popover"

    接下来,为跳跳虎插入LocalizationID(在我的例子中是MenuButton 的ID)。请注意,ID 必须包含在 ["INSERT_YOUR_LOCALIZATION_ID_HERE"] 中,所以在我的示例中,我输入了 ["204"]

    执行这些步骤后,项目将构建,并且 Popover 将正常运行。

    快乐的日子。

    【讨论】:

      猜你喜欢
      • 2012-08-27
      • 2023-03-13
      • 2015-05-21
      • 2015-10-20
      • 2011-09-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多