MKMapView doesn't load map and show yellow background - mkmapview

Once I start the app it should load the map of the city you are in. It worked perfectly in IOS 9-10. Since iOS 11 map started to act strangely. Now when you start the app it shows yellow map. If I click home button, wait 3-5 sec and go back into the app, it will show map like it should... Tried to debug it, change layout structure, nothing helped.. Below you can see screenshots when you open the app first time and after 5 seconds of going back to home screen.
Adding to the view like this:
mapView.isScrollEnabled = false
mapView.isZoomEnabled = false
mapView.isPitchEnabled = false
mapView.isRotateEnabled = false
mapContainer.addSubview(mapView)
mapView.fillSuperview()
And then set map once location is detected like this:
let center = CLLocationCoordinate2D(latitude: mapLatitude - 0.004, longitude: mapLongitude)
let region = MKCoordinateRegion(center: center, span: MKCoordinateSpan(latitudeDelta: 0.04, longitudeDelta: 0.04))
self.mapView.setRegion(region, animated: true)

So the error was in wrong initialisation. I did initialise mapview on the top of the viewController when I was supposed to do it inside viewDidLoad. That fixed the issue.

Related

Electron get height of titlebar / Set 2nd window on same Y coordinate?

Right now I am writing a small app with NodeJS/Electron.
It's basically a map with a customer list, but the customer list should also be able to pop out into a second window.
So far so good, everything is working as it should, but I want the second window to be aligned with the right border of the first window and it should be on the same height/y-coordinate. Like this:
windows aligned
But the problem is that when I set my second windows bounds to the same bounds of the first window it causes the second window to have an offset. And the offset is exactly the height of the titlebar.
See here:
windows not aligned
I'm trying to figure this out for around two weeks now, but I can't seem to find a reliable way to always get that offset. The app will run on Linux and Windows machines, so I can't set a fixed offset.
This is the code I use right now, where the offset occurs:
var window = new BrowserWindow({width: 1000, height:800});
var bounds = electron.screen.getPrimaryDisplay().bounds;
var wBounds = window.getBounds();
window.setBounds({
x: Math.ceil(bounds.width / 2 - wBounds.width / 2),
y: Math.ceil(bounds.height / 2 - wBounds.height / 2),
height: wBounds.height,
width: wBounds.width
});
wBounds = window.getBounds();
extWindow = new BrowserWindow({width: 600 , height: wBounds.height , x: wBounds.x + wBounds.width , y: wBounds.y});
//in my case window.getBounds().y -> 168, extWindow.getBounds().y -> 168
where window is my main window and extwindow is the second one.
When reading window.getBounds().y and extWindow.getBounds().y they're the same. So what is the problem here ? extWindow is not a child of window!
Is there any way to either get the height of the titlebar or disable the new window being offset?
I'm using:
Electron 2.0.5
Electron-Builder 20.21.2
Linux Mint 19 Cinnamon 3.8.8
3m7ecc

Change visible property sometimes change the center position of the view (possible bug?)

I've 3 (loader, locker and debug view) hidden views (touchEnabled and visible set to false, and zIndex to 1) above the main view (zIndex = 2).
Each 'over' view has this method:
$.debugView.show = function() {
$.debugView.touchEnabled = $.debugView.visible = true;
$.debugView.zIndex = 3;
};
$.debugView.hide = function() {
$.debugView.touchEnabled = $.debugView.visible = false;
$.debugView.zIndex = 1;
};
This screen has the 3 'over' views hidden:
Now, I'm opening the 'debug view', but, SOMETIMES it seems like it changes the positions (as if the center it's on the top left corner instead of the center of the device).
Instead of the required result:
If I use the opacity instead of the visible property, it works properly.
This might be an SDK bug right?
<Alloy>
<Window>
<View id="content"/>
<View id="locker"/>
<View id="loader"/>
<View id="debugView"/>
</Window>
</Alloy>
All of these 4 views don't have width or height (so it uses the Ti.UI.FILL as default)
I have noticed this too with a completely different implementation. I had just one view that I included in a window.
Apparently the left and top calculations were not done properly if the elements is hidden.
What I did to solve the issue is to hardcode the left/top position by calculating the left position using this:
$.content.left = (Ti.Platform.displayCaps.platformWidth - 75) / 2;
Where in my case 75 is the width the element has, so that'll be bigger in your case. You can do the same for height.
Now, this is an iOS only solution. On Android you will need to take DPI into consideration calculating it.
I do think it is a bug, though this solution works perfectly for me. I recommend looking at JIRA and see if it is a known issue, and if not, raise it with a very specific explanation of the problem, preferably with a reproducible case delivered as an app. Classic would help most. And if it is not reproducible in classic it might be an alloy issue.

Flash CC Canvas and GSAP: How to set registration point of movieclip on stage

How would I go about changing the registration point of a movieclip labeled "tablet" placed on the stage (root) dynamically?
For example: I have the following:
var tablet = this.tablet; //movieclip labeled "tablet" on stage
function resetTablet(){
tablet.regX = tablet.width/2; //move registration point to center
tablet.regY = tablet.height/2;
}
However when I call it using GSAP:
var tl = new TimelineLite();
tl.to(tablet, 1, {alpha:1, onComplete:resetTablet})
.to(tablet, 3, {alpha:0, scaleX:1.5, scaleY:1.5})
the registration point is still set to the upper left corner rather than the center.
What am I doing wrong here? Thanks!
Registration points affect change both the transformation point, but also the position. If you set a displayobject that is 100x100 pixels to regX=50;regY=50, then it will draw from that point, moving the content 50px to the top and left. If you make that change you should also translate the clip to x=50;y=50.
An issue with you example is that there is no width or height on EaselJS content (explained here). You can get the bounds of anything generated by Flash CC using the nominalBounds property, which Flash exports as a property on every object. If you have multiple frames, you can turn on "multi-frame bounds" in the publish settings, and a frameBounds property is added to the objects as well.
Note that nominalBounds and frameBounds are not used by the getBounds method.
Here is how you might be able to approach it.
var bounds = tablet.nominalBounds;
tablet.regX = bounds.width/2;
tablet.regY = bounds.height/2;
// Optional if your actual registration point was [0,0] before:
tablet.x += tablet.regX;
tablet.y += tablet.regX;
Hope that helps.

Custom controls not visible in the View

Below is my code I used to create a custom UITextField in code behind.
UITextField usernameField;
usernameField = new UITextField
{
Placeholder = "Enter your username",
BorderStyle = UITextBorderStyle.RoundedRect,
Frame = new RectangleF(10, 32, 50, 30)
};
View.AddSubview(usernameField);
But when I run my app, I dont see this anywhere. Not only this control but all the controls that I create in code behind.
If I drag the controls from toolbox onto my View it's working very fine.
What might be the cause?
Make sure that Container View is not transparent so Alpha = 1 and set background colors for appropriate controlls. Because by default its set to ClearYou can use this method to easly set background and rounded corners like in older versions of iOS
public static void MakeViewRounded(UIView view,float cornerRadius, MonoTouch.CoreGraphics.CGColor backgroundColor)
{
view.Layer.CornerRadius = cornerRadius;
view.Layer.BackgroundColor = backgroundColor;
}
Also make sure that you adding your custom controll to ViewController/View

Move MKMapView legal label on rotation

I have an MKMapView with an iAd banner on top. Due to this iAd Banner covering the MKMapView's legal label, it is moved. The following code is performed in viewDidLayoutSubviews:
NSLog(#"ViewDidLayoutSubviews called");
UILabel *attributionLabel = [self.mapView.subviews objectAtIndex:1];
if (adBannerViewFrame.origin.y < attributionLabel.frame.origin.y) {
NSLog(#"Banner Y coordinate: %f", adBannerViewFrame.origin.y);
CGRect legalFrame = attributionLabel.frame;
legalFrame.origin.y -= IAD_BANNER_HEIGHT;
attributionLabel.frame = legalFrame;
NSLog(#"Legal y: %f", legalFrame.origin.y);
NSLog(#"Legal x: %f", legalFrame.origin.x);
NSLog(#"Legal width: %f", legalFrame.size.width);
NSLog(#"Legal height: %f", legalFrame.size.height);
}
When I switch from the View Controller containing the map to another VC and back again, the code above works perfect, regardless of orientation; however, when rotating the devices without switching VCs, the legal label disappears on rotation and don't come back until I switch back and fourth between VCs again. The NSLogs print out the exact same for both rotation and VC switching:
ViewDidLayoutSubviews called
Banner Y coordinate: 902/646(rotation dependent)
Legal x: 882/626(rotation dependent)
Legal y: 11
Legal width: 48
Legal height 11
Despite everything looking the same, the label is gone after rotating (not sure if it is moved out of the view or if it actually disappears)
The iAd Banner is reloaded in ViewDidAppear (which is called when VCs are switched back and fourth). However, since the NSLogs print the same for both scenarios, I cannot see how it should make any difference. To be sure, I tried to reload the iAd Banner in ViewDidLayoutSubviews as well, with no different result than before. Anyone experienced anything similar or know how to fix this?
For anyone encountering the same issue, I found a solution. The workaround was to schedule a timer with 0 seconds and have the timer call the method executing the code above.
[NSTimer scheduledTimerWithTimeInterval:0 target:self selector:#selector(test) userInfo:nil repeats:NO];
I assume that something was not completely finished when viewDIDlayoutSubviews was called and that adding a timer (which is not 100 % accurate and will therefore not start immediately), allowed the unknown remaining stuff to complete before the code in the question was executed.

Resources