2
votes

I am getting an exception on my second line of code here. I am calling this code from within ViewDidLoad. _assetURLs[page] (in this case page is 0), is returning a single assetURL that exists and was already retrieved.

UIImage img;
img = new UIImage(new MonoTouch.CoreImage.CIImage(_assetURLs[page]));

Any ideas?

Here is the exception: (the exception is happening because of --> new UIImage(...) and not because of new MonoTouch.CoreImage.CIImage(_assetURLs[page])

{MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown. Name: NSInvalidArgumentException Reason: -[UIImage initWithCIImage]: unrecognized selector sent to instance 0x107a1fc0 at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging:IntPtr_objc_msgSend_IntPtr (intptr,intptr,intptr) at MonoTouch.UIKit.UIImage..ctor (MonoTouch.CoreImage.CIImage ciImage) [0x00027] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIImage.g.cs:376 at ScrollViewPageViewExample.Viewer.LoadPageContent (Int32 page) [0x0002e] in /Users/user1/Dropbox/Dev/ScrollViewPageViewExample/ScrollViewPageViewExample/Viewer.cs:148 }

1
I'm not a monotouch user, but what exactly does "new" mean because it looks to me like you're trying to initialize the same UIImage twice. Try UIImage img = new UIImage(new MonoTouch.CoreImage.CIImage(_assetURLs[page])); - jhilgert00
new, creates a new instance of the object. If I remember correctly this is similar to initialize an object in obj-c. The syntax here is correct. I am first initializing a CIImage with an Asset URL as part of the initialization to get that asset image url. Then I am initializing a new UIImage with the CIImage being initialized with it (passed in as an argument to the constructor in C#) - user1060500
Where is that code executed ? device or simulator ? and using which version of iOS ? i.e. that selector is new in 5.0 (4.3 would throw that ObjC exception). - poupou

1 Answers

3
votes

That an (already fixed, but not yet released) bug in MonoTouch.

You can use the overloaded constructor that accept a float and an UIImageOrientation as a workaround.

UIImage img = new UIImage (your_ciimage, 1.0f, UIImageOrientation.Up);