C# C Xamarin-Popover segue导致匿名生成错误
首先,了解相关环境细节可能有助于您排除环境因素:C# C Xamarin-Popover segue导致匿名生成错误,c#,ios,xamarin,segue,viewcontroller,C#,Ios,Xamarin,Segue,Viewcontroller,首先,了解相关环境细节可能有助于您排除环境因素: 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)
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)
通过查看,我无法通过以下问题解决问题,通常在Xamarin文档中
在构建时,我在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]
我在Main.storyboard的菜单按钮上按住CTRL键并左键单击,然后正确地拖动到创建Segue的NavigationDropdownViewController。我把这个命名为segue NavigationMenuSegue
在小部件选项卡中,我设置了以下内容:
如果我从Adaptive Segue树中选择Present As Popover,或者从弃用的Segue树中选择Popover,则构建操作会遇到上述错误
奇怪的是,如果我选择现在模式或按下选项,下拉菜单会在点击菜单按钮时出现——尽管位置不对!本质上,我希望它切换为一个弹出框,插入符号指向菜单按钮,这是我被要求的
我只想让下拉菜单出现在菜单按钮下方,与基于网络的汉堡包菜单的样式非常相似。。。根据Xamarin的Bugzilla,我担心这不是一个孤立的问题
在Xcode中,我可以简单地删除视图并使用.xib轻松地进行分割-我似乎不太理解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;
}
}
}
[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
}
}
NavigationBarDropDownViewController.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;
}
}
}
[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构建错误是框架中的一个bug,还是我在创建一个非常简单的菜单->下拉UI模式时完全走错了路
感谢您花时间阅读本文并为解决方案做出贡献,因为我不能再为此而掉头发了
约翰好的
我希望这能帮助其他使用Xamarin.IOS设计器遇到此问题的人
我从与Xamarin开发人员的交谈中了解到,这个问题现在已经在最新的4.1.x版本中得到了解决,该版本目前正在其Beta版中。但是,那些更愿意使用稳定构建(即4.0.x)的用户则遵循以下步骤来解决匿名构建错误:
首先,选择您希望触发Popover的UI元素,在我的例子中是MenuButton。请注意LocalizationID,您可以通过单击设计器中的元素并查看Properties窗口来找到它。在我的例子中,菜单按钮的本地化ID是204:
现在单击Segue,再次导航到Properties窗口。从Segue下拉列表中选择Present As Popover
接下来,在我的示例菜单按钮ID中插入跳跳虎的本地化ID。请注意,ID必须包含在[insert_YOUR_LOCALIZATION_ID_HERE]中,因此在我的示例中输入[204]:
遵循这些步骤后,项目将构建,Popover将正常运行
快乐的日子