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 }
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);
Related
Here Explore
init(coordinates: GeoCoordinates, image: UIImage) {
let pngData = image.pngData()
let mapImage = MapImage(pixelData: pngData!, imageFormat: ImageFormat.png)
print("i did print")
self.mapMarker = MapMarker(at: coordinates, image: mapImage)
}
This is the error message -
dyld4 config: DYLD_LIBRARY_PATH=/usr/lib/system/introspection
DYLD_INSERT_LIBRARIES=/Developer/usr/lib/libBacktraceRecording.dylib:/Developer/usr/lib/libMainThreadChecker.dylib:/Developer/Library/PrivateFrameworks/DTDDISupport.framework/libViewDebuggerSupport.dylib:/usr/lib/libMTLCapture.dylib
terminating with uncaught exception of type std::runtime_error: SDK
engine is null. Please provide a valid object.
pngData isn't a nil value when the MapImage constructor is called, I checked it by printing. What does this error mean and how can I fix it?
I figured this out myself. The crux of the issue is that before creating the MapImage instance the HereSDK engine needs to be initialized which can be done in 2 ways-
Initialize the MapView which in turn initializes the HereSDK engine but in my case this initialization was happening after the MapImage instance initialization statement.
Initialize the engine explicitly before the MapImage instance initialization statement.
do {
try SDKInitializer.initializeIfNecessary()
} catch {
fatalError("Failed to initialize HERE SDK. Cause: (error)")
}
This can be done in the AppDelegate file as well.
I am working with SVGKit in swift Project. I properly imported SVGKit Framework and 3rd party resources folder into my project by following (https://github.com/SVGKit/SVGKit).
I created a folder with sets of .svg images inside the project and i am using the following code to load image into testIcon(ImageView).
let lockImage: SVGKImage = SVGKImage(named: "LockIcon.svg")
let lockImageLocal: UIImage = lockImage.uiImage
testIcon.image = lockImageLocal
But i am receiving the following error,
** Assertion failure in +[SVGKImage imageWithSource:], /Users/fss/Downloads/SVGKit-
2.x/Source/SVGKImage.m:229
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not
satisfying: newSource != nil'
Please let me know how to mention path of .svg image(which is inside my project) to SVGKImage image class or how to resolve this problem.
please remove .svg from image name. This method named: doesn't need extension.
Or you can try this way too...
Swift 4
if let imagePath = Bundle.main.path(forResource: "imageName", ofType: "svg")
{
let lockImage: SVGKImage = SVGKImage(contentsOfFile: imagePath)
let lockImageLocal: UIImage = lockImage.uiImage
testIcon.image = lockImageLocal
}
Obj-c type
NSString *imagePath = [NSBundle mainBundle][ pathForResource:#"imageName" ofType:#"svg"];
UIImage *image = [UIImage imageWithContentsOfFile:imagePath];
App keeps crashing on this Method - trying to simply pin a Parse object to the local data store as outlined in the docs Parse docs:
func saveToBackground(title:String, description:String, coords:CLLocationCoordinate2D, image:UIImage, objectId:String, dateFound:String){
let imageData = image.jpeg(.low)
let imageFile = PFFile(name: "image.png", data: imageData!)
let foundObject = PFObject(className: "FoundObjects")
foundObject["title"] = title
foundObject["description"] = description
foundObject["coordinates"] = coords
foundObject["image"] = imageFile
foundObject["objectId"] = objectId
foundObject["dateFound"] = dateFound
foundObject.pinInBackground()
}
error:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'PFObject values may not have class: NSConcreteValue'
Any ideas anyone?
At least one of your values is an NSConcreteValue class, which can't be stored on a PFObject. Figure out which line is causing the issue by setting a breakpoint and stepping through, and make sure to cast that value to the expected class. Or you could cast all of these to their expected class, cover your bases.
Edit: As pointed out by MartynE23, the issue was actually the CLLocationCoordinate2D, which must be converted to a PFGeoPoint to add to a Parse Object
i find this problem but did't give me answer,
while i set value to custum slider then given me error as below
Terminating app due to uncaught exception 'CALayerInvalidGeometry', reason: 'CALayer position contains NaN: [nan 15.5]'
below is my code while i set cusumslider value using MPMoviePlayerController
double loadTime = floor(moviePlayerController.playableDuration);
double currentTime = floor(moviePlayerController.currentPlaybackTime);
double totalTime = floor(moviePlayerController.duration);
[self setTimeLabelValues:currentTime totalTime:totalTime];
NSLog(#"%f",currentTime);
custom_slider.value = ceil(currentTime);
also try with custom_slider.value = ceilf(currentTime); but did't sloved this issues
while i comment on custom_slider.value = ceil(currentTime); this line then application work fine.
please help me out
I'm developing an iOS 5.0+ app with latest SDK.
On my app I have some C++ image recognition software, and I'm trying to save image recognized by this C++ functions.
I have this array to store image recognized:
int _detectedImages[NSMaxNumDetections ][NSPatchSize * NSPatchSize];
I call the C++ function this way:
numberOfDetections = nativeDetect(_resultImages);
And with the following code, I try to convert data from _detectedImages to UIImage.
for (int index = 0; index < numberOfDetections; index++)
{
if (_resultImages[index] != nil)
{
NSData* imageData = [NSData dataWithBytes:&_resultImages[index] length:sizeof(_resultImages[index])];
NSLog(#"##### Image data size: %d", [imageData length]);
UIImage* newImage = [UIImage imageWithData:imageData];
_lastDetectedSignImages[index] = newImage;
}
}
On the log I get this:
#### Image data size: 2304
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSArrayM setObject:atIndex:]: object cannot be nil'
*** First throw call stack:
newImage is nil but imageData has data.
Am I doing something wrong when I try to get an UIImage from that data?
The other possibility if that my C++ recognition software is doing something wrong, but I'm not going to show you that code here (sorry, it's copyrighted).
Or I'm not passing _resultImages correctly to nativeDetect.
Almost for sure your C++ images are in some bitmap format - RGBA etc. So your first task is to figure out what that format is (and the byte order too!). With that information you can use CGImageCreate() to create a CGImageRef. With that you can create a UIImage.