我有一个非常简单的单点触控应用程序,我试图在uiimageview中引用图像,但我没有成功。下面是代码清单和我不断得到的错误。请帮帮忙。我不知道我做错了什么,我已经仔细检查过GoldenGate.jpg是我项目的一部分
using System;
using System.Collections.Generic;
using System.Linq;
using MonoTouch.Foundation;
using MonoTouch.UIKit;
namespace helloworld10
{
public class Application
{
static void Main (string[] args)
{
UIApplication.Main (args);
}
}
// The name AppDelegate is referenced in the MainWindow.xib file.
public partial class AppDelegate : UIApplicationDelegate
{
// This method is invoked when the application has loaded its UI and its ready to run
public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
// If you have defined a view, add it here:
// window.AddSubview (navigationController.View);
UIImage image = UIImage.FromFile("GoldenGate.jpg");
UIImageView imageview = new UIImageView(image);
Console.WriteLine ("hello world");
window.MakeKeyAndVisible ();
return true;
}
// This method is required in iPhoneOS 3.0
public override void OnActivated (UIApplication application)
{
}
}
}但是,我得到了以下错误。请帮帮我
Error connecting stdout and stderr (127.0.0.1:10001)
Unhandled Exception: System.ArgumentNullException: Argument cannot be null.
Parameter name: image
at MonoTouch.UIKit.UIImageView..ctor (MonoTouch.UIKit.UIImage image) [0x00064] in /Users/plasma/Source/iphone-3/monotouch/UIKit/UIImageView.g.cs:106
at helloworld10.AppDelegate.FinishedLaunching (MonoTouch.UIKit.UIApplication app, MonoTouch.Foundation.NSDictionary options) [0x0000b] in /Users/zulfiqarsyed/Projects/helloworld10/helloworld10/Main.cs:28
at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/plasma/Source/iphone-3/monotouch/UIKit/UIApplication.cs:26
at MonoTouch.UIKit.UIApplication.Main (System.String[] args) [0x00000] in /Users/plasma/Source/iphone-3/monotouch/UIKit/UIApplication.cs:31
at helloworld10.Application.Main (System.String[] args) [0x00000] in /Users/zulfiqarsyed/Projects/helloworld10/helloworld10/Main.cs:14 发布于 2011-07-30 05:59:02
看起来像是个虫子。图像必须放在文件夹中,例如@"Images/GoldenGate.jpg" (构建操作设置为"Content")
发布于 2011-04-22 12:58:54
项目中的文件名为"GoldenGate.jpg“吗?请记住,iOS设备区分大小写,而仿真器仅区分大小写。您是否也将文件标记为项目中的内容?
发布于 2014-11-14 21:59:39
我也有同样的问题。当它找不到有问题的图像时,就会出现错误。当A)某个内容拼写错误时,例如图像名称(区分大小写),或者路径错误并且B)文件没有被标记为"Content“时,就会发生这种情况。
其他每个人都已经提到将其标记为内容,我将详细说明文件的位置。您可以将其存储在根目录下,或者更好地创建一个文件夹,并将其命名为您喜欢的任何名称。然后将图像引用为
var image = UIImage.FromBundle (“文件夹名称/GoldenGate.jpg”);
https://stackoverflow.com/questions/5752357
复制相似问题