在MonoTouch MonoDevelop中重命名Controller类 [英] Renaming Controller classes in MonoTouch MonoDevelop

查看:52
本文介绍了在MonoTouch MonoDevelop中重命名Controller类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

重命名继承UIViewController并具有链接到情节提要的designer.cs类的类的最佳方法是什么?

What is the the best way to rename a class which inherits a UIViewController and has a designer.cs class linked to a storyboard?

我首先尝试在MonoDevelop中重命名.cs文件.此方法有效,但designer.cs文件未使用其重命名,类名也未使用.

I first tried to Rename the .cs file in MonoDevelop. This worked but the designer.cs file did not get renamed with it, and neither did the class name.

然后,我将重命名为类名.这成功更改了.cs和.designer.cs文件中的类名,但仍然没有更改.designer.cs文件名.它还没有更改Xcode中控制器的自定义类"的名称.

I then renamed the class name. This successfully changed the class name in both the .cs and .designer.cs files but still did not change the .designer.cs filename. It also did not change the name of the "Custom Class" for the controller in Xcode.

因此,在XCode中,我更改了自定义类的名称并保存,然后切换回MonoDevelop,令我感到恐惧的是,它创建了一个与重命名的名称相同的新.cs和一个新的.designer.cs文件.在原始的(重命名).cs文件下(未重命名)放在a.designer.cs文件旁边!

So in XCode I changed the name of the Custom Class and saved then switched back to MonoDevelop , to my horror it had created a new .cs with the same name as the renamed one and a new .designer.cs file which it put under the original (renamed) .cs file next to the old (not renamed) a.designer.cs file!

谁能告诉我应该采取的步骤顺序?

Can anyone tell me the sequence of steps I should have taken?

推荐答案

重命名文件非常棘手,因为MD不支持重命名分组的文件.您必须手动编辑csproj,或从项目中删除文件,在Finder中重命名,然后重新添加.

Renaming the file is tricky, since MD doesn't support renaming grouped files. You'd have to manually edit the csproj, or remove the files from the project, rename in Finder, and add them back.

重命名该类稍微容易一些,但是关键是要了解该类实际上有两个名称-.NET名称和Obj-C名称.重命名.NET名称应该很容易,您只需在MD中使用重命名命令即可.

Renaming the class is somewhat easier, but the key is to understand that the class actually has two names - the .NET name, and the Obj-C name. Renaming the .NET name should be easy, you can simply use the rename command in MD.

Obj-C名称应用于[Register("SomeName")]属性上的类,并且是xib和Xcode中使用的名称.但是,请注意,MonoDevelop将尝试创建它认为在Xcode中创建的任何类的.NET对应版本.这意味着您应该首先在MonoDevelop中更改Obj-C名称,然后切换到Xcode并在那里更改自定义类.

The Obj-C name is applied to the class on the [Register("SomeName")] attribute, and is the name that's used in xibs and in Xcode. However, beware that MonoDevelop will attempt to create .NET counterparts of any classes that it thinks were created in Xcode. This means you should change the Obj-C name in MonoDevelop first, then switch to Xcode and change the Custom Class there.

这篇关于在MonoTouch MonoDevelop中重命名Controller类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆