将资源添加到 MonoTouch 项目
我是 MonoTouch 的新用户,想知道如何将图像文件添加到项目中。所描述的方法都不起作用。 MonoTouch Wiki 说右键单击该项目,会出现一个菜单,允许“添加”新文件。我没有看到这样的右键菜单。
另外,有人发布了一个解决方法,其中使用与 MonoTouch 应用程序相同的文件夹目标创建一个虚拟 Xcode 项目,然后 Xcode 将建立 Resources 文件夹并允许导入资源文件(在我的例子中是 .JPG 文件)。
我什至不需要使用 Interface Builder 将图像文件附加到控件;我的意思是:我什至无法将图像文件放入我的 MonoDevelop 项目中。
我还尝试在项目文件夹中创建一个 Resources 子文件夹并将图像文件放入其中。运气不好。
谁能提供向 MonoTouch 项目添加资源的完整过程?非常感谢。
I am a new user of MonoTouch and wondering how to add image files to a project. None of the ways described work. The MonoTouch Wiki says to right-click the project and a menu should appear allowing one to "add" new files. There is no such right-click menu that I see.
Also, someone posted a workaround where a dummy Xcode project is created using the same folder destination as the MonoTouch application and then Xcode would establish the Resources folder and allow for the import of resource files (in my case a .JPG file).
I am not even to the point of needing to attach the image file to a control using Interface Builder; I mean: I can't even get the image file into my MonoDevelop project.
I've also tried creating a Resources subfolder inside my project folder and dropping the image file in there. No luck.
Can anyone provide a thorough procedure for adding resources to a MonoTouch project? Much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该在解决方案板中右键单击您的项目:
上下文菜单就在那里,相信我。该项目就在解决方案的下方。
之后,您必须将图像文件的“构建操作”设置为“内容”,这次再次右键单击图像文件:
要使用代码中的图像,请键入:
一切都准备好了!您可以在项目中创建所需的所有文件夹,但不能创建名为“Resources”的文件夹。编译时你会得到一个错误。在 MonoTouch 3.2.5 中至少...
You should right-click on your project in the Solution pad:
The context-menu is there, trust me. The project is just below the solution.
After that, you have to set your image file's Build Action to Content, again by right-clicking on the image file this time:
And to use the image from your code, you type:
And you are all set! You can create all the folders you want in the project, but NOT a folder named "Resources". You will get an error upon compilation. In MonoTouch 3.2.5 at least...