如果我使用的是Visual Studio for Mac,则它在设计器中具有此字段。
它在View.cs文件中创建一个属性,允许我绑定到该属性。
我在xcode中找到了类似的部分(这是车手打开的地方),并且只有这些选项。没有名称字段。
此名称字段不是按钮标签上显示的内容。我知道该怎么设置。
对于Mac,我更愿意使用Rider而不是Visual Studio。如果我必须不断跳来跳去,这显然是个问题。
编辑:据我所知,似乎是在编辑View.designer.cs。
尽管有此评论。如何从Rider中进行编辑?
// WARNING
//
// This file has been generated automatically by Visual Studio from the
outlets and
// actions declared in your storyboard file.
// Manual changes to this file will not be maintained.
//
这是新的MvvmCross项目默认情况下的样子
using Foundation;
using System;
using System.CodeDom.Compiler;
namespace HelloCrossPlatform.iOS.Views
{
[Register ("FirstView")]
partial class FirstView
{
[Outlet]
[GeneratedCode ("iOS Designer", "1.0")]
UIKit.UILabel Label { get; set; }
[Outlet]
[GeneratedCode ("iOS Designer", "1.0")]
UIKit.UITextField TextField { get; set; }
void ReleaseDesignerOutlets ()
{
if (Label != null) {
Label.Dispose ();
Label = null;
}
if (TextField != null) {
TextField.Dispose ();
TextField = null;
}
}
}
}
这是当我使用Designer将name属性添加到Visual Studio for Mac中的按钮时的外观
using Foundation;
using System;
using System.CodeDom.Compiler;
namespace HelloCrossPlatform.iOS.Views
{
[Register ("FirstView")]
partial class FirstView
{
[Outlet]
[GeneratedCode ("iOS Designer", "1.0")]
UIKit.UILabel Label { get; set; }
[Outlet]
[GeneratedCode ("iOS Designer", "1.0")]
UIKit.UIButton SayHelloButton { get; set; }
[Outlet]
[GeneratedCode ("iOS Designer", "1.0")]
UIKit.UITextField TextField { get; set; }
[Action ("UIButtonDZD114An_TouchUpInside:")]
[GeneratedCode ("iOS Designer", "1.0")]
partial void UIButtonDZD114An_TouchUpInside (UIKit.UIButton
sender);
void ReleaseDesignerOutlets ()
{
if (Label != null) {
Label.Dispose ();
Label = null;
}
if (SayHelloButton != null) {
SayHelloButton.Dispose ();
SayHelloButton = null;
}
if (TextField != null) {
TextField.Dispose ();
TextField = null;
}
}
}
}
骑士甚至是与Xamarin一起使用的好工具吗?我对他们甚至将其作为一种选择感到失望。真的在质疑我对JetBrains的订阅。Vscode似乎和Webstorm一样好,Webstorm是我与他们合作的唯一其他产品。
答案 0 :(得分:2)
Rider没有.xib
和.storyboard
UI文件的特殊设计器。我们(Rider团队)认为我们将无法实现与本机xcode一样好的(和实际的)UI设计器。因此,在Rider中使用Xamarin macios UI的主要方案-使用xcode接口构建器。
您可以查看有关网点生成的Apple文档: https://developer.apple.com/library/archive/documentation/ToolsLanguages/Conceptual/Xcode_Overview/ConnectingObjectstoCode.html
这是简要说明如何在xcode 11中使用默认设置进行操作。
Ctrl +单击要绑定的控件并将其拖动到代码中。 重要说明:使用.h文件创建新的操作和方法,Rider分析.h文件以建立公共API模型。
现在,您可以输入将要创建绑定的控件的名称。您将在objc代码中看到相应的出口。
也许不是那么简单,所以我将尝试解释其内部工作方式。 Xamarin macios项目是一个(几乎)常规的.NET C#项目。因此,为了允许您在xcode中编辑UI,Rider(和VS实际上)做了一些魔术。它需要.NET项目和:
obj\xcode
文件夹中使用特定的设置和配置创建相应的xcodeproj(pbxproj和朋友)项目。ViewController
类型。骑士会为他们每个人生成带有动作和出口的objc类。 在生成的项目中进行了一些更改并返回到Rider后,它将尝试应用所有更改:
*.designer.cs
文件。对于所有这些文件,您将看到此生成的标头(以后可以更改):// WARNING
//
// This file has been generated automatically by Rider IDE
// to store outlets and actions made in Xcode.
// If it is removed, they will be lost.
// Manual changes to this file may not be handled correctly.
//
要控制xcode同步过程并查看发生了什么并查看发生了什么错误,可以使用特殊的Rider工具窗口:xcode console
。每次您使用xcode打开项目时都会显示该信息:
并非得出结论:Rider的团队试图为Xamarin开发人员提供良好的体验,甚至比VS for Mac更好。因此,我们正在努力支持Xamarin的某些部件(2020.1中的Xamarin Forms Hot Reload),因此可以随时在我们的公共问题跟踪器中分享您的麻烦:
https://youtrack.jetbrains.com/issues/RIDER?q=Technology:%20Xamarin%20