Changing CurrentPositionView in Skobbler/skmaps not working - ios

I wanted to change to default current position marker of skmaps.
I have tried this:
self.mapView.currentPositionView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"nui-img-car"]];
But this is not working. It is still showing default position marker.
And advice please.

I tried the following in the demo project and it worked flawlessly:
self.mapView.currentPositionView = [[UIImageView alloc]
initWithImage:[UIImage imageNamed:#"picture"]];
picture.png is in the /Resources folder

Related

Since the last Xcode update I can't work with images

This is the basic code I use to add an image named "Background.png" to an UIImageView:
UIImageView *imageView = [[UIImageView alloc] init];
imageView.image = [UIImage imageNamed:#"Background.png"];
imageView.frame = CGRectMake(0.0, 0.0, self.view.frame.size.width, self.view.frame.size.height);
[self.view addSubview:imageView];
Since the last Xcode update the resource can't be loaded.
I tried running on an iPhone 6 - iOS 10.3 and the Simulator - iOS 11.0
For some reason even though the iOS deployment target is version 10.3 the simulator runs on iOS 11.0
The image is there, in the same folder as the project named: "Background.png"
I've been doing the same thing for years and now it has stoped working.
Anyone had a similar issue?
You may want to utilize the purpose of Assets.xcassets. Put your assets there and you can easily use your images. Note that you do not have to put the image's file extension. It's easy, like so:
UIImage *markerImage = [UIImage imageNamed:#"marker"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:markerImage];
[imageView setFrame:CGRectMake(0, 0, 100, 100)];
[self.view addSubview:imageView];
I have an image in my Assets.xcassets named marker.
Edit: this is tested, I made an Objective-c project just for this question :)
I had the same problem and i solved it as follow:
Simply Select your image, then check the box linked to your projet name in "Target Membership" (on the Right Window)
is it working ?
There is a Screenshot if needed:
https://i.stack.imgur.com/gTOGJ.png

Image not resizing properly to fit the screen

Im currently stylizing my login screen of my app, but I am running into a problem that i can't solve and is very odd... The image is not resizing properly and kind of starts to repeat itself, which i find very weird because i have the correct image sizes and have them correctly named, and i am calling them in my code correctly too, so i cannot find my problem. Below is the code.
self.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:#"sl_login_default"]];
colorWithPattern is meant to create a pattern out of an image. If you want to have an image in the background, create a new UIImageView
UIImageView *backgroundImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:imageName];
backgroundImageView.frame = self.view.bounds;
[self.view addSubview:backgroundImageView];

UIImageView completely wrong position in UIView

I'm trying to add an UIImageView to a UIView that I created.
However, the position of the image is way too low inside the UIView, even though I set the frames to be equal.
The UIView is called photoView, here is what I did:
UIImageView *imgV = [[UIImageView alloc] initWithImage:[UIImage imageNamed:#"image1.JPG"]];
imgV.frame = self.photoView.frame;
[self.photoView addSubview:imgV];
You can see the result (and the position of photoView in the storyboard) here:
I have no idea how to fix this, adding
imgV.center = self.photoView.center;
imgV.contentMode = UIViewContentModeScaleToFill;
doesn't help either.
Try this:
imgV.frame = self.photoView.bounds;
instead of this:
imgV.frame = self.photoView.frame;
Nevermind, I found the answer, but I'll leave this up here in case anyone else has this question.
The mistake was in the difference between frame and bounds. This is where I found my answer.
My solution was this:
[imgV setFrame:CGRectInset(self.photoView.bounds, 0, 0)];

Image is showing on simulator but not on a real iPhone

So I got this piece of code, I want to show a picture on my view:
imgLogo = [[UIImageView alloc] init];
[imgLogo setFrame:CGRectMake(60, 200, 200, 200)];
[imgLogo setImage:[UIImage imageNamed:#"MyFrigginAwesomeLogo"]];
[self.view addSubview:imgLogo];
But the problem is that it works correctly when testing it on the simulator(iOS 7) but it doesn't show anything on my iPhone(4S with iOS7) itself.
Answer added from Comment:
The iOS devices are case sensitive, but the simulator is not. Make sure you are trying to load the exact filename in order for them to be found.
Try using the designated initializer for UIImageView instead of just init:
NSString *logoName = #"MyFriggingAwesomeLogo";
imgLogo = [[UIImageView alloc] initWithImage:[UIImage imageNamed:logoName]];
imgLogo.frame = CGRectOffset(imgLogo.frame, 60, 200);
[self.view addSubview:imgLogo];
It's also possible that you've added the image resource to only the simulator target. In your bundle settings Build Phases, make sure you have the image listed in Copy Bundle Resources.

How do I change the position of this element on the ViewController programatically?

I have this code in my ViewController.m but there is no Strobyboard/XIB file for it which is fine but on the screen the element comes up in the centre automatically. How Do I add a custom position to it?
UIImageView *bgImageView = [[UIImageView alloc] initWithImage:_bgImage];
[self addSubview:bgImageView];
As far as I'm aware I should be able to add CGRectMake code somewhere but I can't figure it out.
Any suggestions?
bgImageView.frame =CGRectMake(x,y,width,height);
If you want to maintain the previous values:
bgImageView.frame =CGRectMake(x,y, bgImageView.frame.sizewidth, bgImageView.frame.size.height);

Resources