MKMapView night mode like in iOS7 Apple Maps? - cocoa-touch

Is there an easy way to enable night mode on a MKMapView like the Apple Maps apps does when the sun is down ?
I didn't find such a thing the MapKit documentation.

Unfortunately it is a private api:
//add this above the interface of the class you want to try it on
#interface MKMapView ()
-(void) _setShowsNightMode:(BOOL)yesOrNo;
#end
//call this in your viewDidLoad or somewhere else appropriate
[self.mapView _setShowsNightMode:YES];
We should file a radar for apple to open this up to everyone. It could be a safety issue for people using maps in third party apps while driving. Your app will be rejected if you try and submit it to the app store using this.

No, you'd have to use a third-party library like Mapbox iOS SDK or MBXMapKit.

Related

In React Native Library How Can I get ios current UIViewController

react native library in android can use "getCurrentActivity()" to replace "this"
final Activity activity = getCurrentActivity();
And In ios How can use to replace "self" to get current UIViewController
For "current UIViewController" you most probably needs RCTPresentedViewController function from RCTUtils.h file:
#import <React/RCTUtils.h>
// ...
UIViewController* vc = RCTPresentedViewController();
// ...
Note: Very old RN versions do not has this API, but it can be easy implemented by hands, implementation is easy enough: RCTUtils.m
On iOS - unless you use wix's react native navigation - there is generally only one UIViewController, instantiated in your AppDelegate.
1st question: Why do you need your app UIViewController ?
if you really need to access it, here is a suggestion : UIApplication.sharedApplication().window.rootViewController (this code might not work for complex native setup, but for simple cases, it should give you your app ViewController)

Watch Kit: is it possible to vibrate watch programmatically?

Is it possible to vibrate watch while Watch Extension is running? We can do it on iOS in this way (force iPhone to vibrate):
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
I hope there is something similar on WatchKit.
Update: I have added issue to Apple radar and recieved the answer:
Engineering has determined that your bug report (20019274) is a duplicate of another issue (19025053) and will be closed.
19025053 is still open.
Update 2: AudioServicesPlayAlertSound() not working on watch simulator with any sound ID. Seems like function is not supported.
You can now ask the Watch to vibrate if you target watchOS 2.0
To do this all you need to do is call playHaptic on a WKInterfaceDevice instance with any WKHapticType. In the example below it will play the notification haptic.
Swift 3
WKInterfaceDevice.current().play(.notification)
Objective-C
[[WKInterfaceDevice currentDevice] playHaptic:WKHapticTypeNotification];
You can further read the
Apple WKInterfaceDevice Documentation
That's a great question, but unfortunately the answer is no. WatchKit doesn't have any APIs available to control haptic feedback. If you would really like to see this feature supported, I'd suggest you file a radar as a feature request.
This is the answer in objective-c after watchOS 2
[[WKInterfaceDevice currentDevice] playHaptic:WKHapticTypeNotification];
With WatchKit, you have to remember that your code runs on the iPhone and not on the watch. Therefore, AudioServicesPlaySystemSound call from a WatchKit extension would run on the iPhone, not on the watch. It will make the iPhone vibrate.

Parse Starter Project for iPad

I know it's very vague and is asking a lot but does anyone know how to convert the standard iOS starter project from iPhone to iPad (both is best)? Or does anyone know where I can download one. I am a new iOS developer and am trying to start learning with Parse.
I am referring to this project https://www.parse.com/downloads/ios/parse-starter-project/latest
P.S. Just because this question isn't perfect doesn't mean you have to go and down vote and flag it for removal I don't have a lot of points already no need to lose even more :)
Not being able to see this sample project, it's hard to say for certain what it will take.
At bare minimum go into your project summary, and select "Universal" for the device support.
Above and beyond that, it just depends on what the app is and how it's structured. For NIBs, you will want a NIB for iPhone and one for iPad. I find it easy to abstract this away so that I can simplify my view loading:
MyController *myController = [[MyController alloc] initWithView:#"MyControllerView" bundle:nil];
Then in a category, I'd define initWithView similar to:
#implementation UIViewController (Universal)
-(id) initWithView:(NSString *)view bundle:(NSBundle *)nibBundle{
bool isIpad = UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad;
NSString *nibName = [NSString stringWithFormat:#"%#_%#", view, (isIpad ? #"iPad" : #"iPhone")];
return [self initWithNibName:nibName bundle:nibBundle];
}
#end
But, that's just one aspect of supporting both devices. In reality the subject is rather specific to the app you're working on. Things like OS support (e.g., am I only targeting iOS 6 or higher) play a factor in things.
I have solved it now, if anyone needs the files email me turboecreations#iCloud.com I would upload them but I dont want my MediaFire and other accounts to be removed if I run into copyright issues.

Cannot find protocol declaration for 'UIWebViewDelegate'

I am trying to utilize UIWebView functionality, specifically I want to do something like this: Open links in Safari instead of UIWebVIew?
But I am having an issue when I try and add the UIWebViewDelegate to my AppDelegate interface.
Anyone know what the issue is? Note this is Mac OS not iOS.
Add:
#import <UIKit/UIKit.h>
Anyone know what the issue is? Note this is Mac OS not iOS.
That's the issue right there.
There is no UIWebView or UIWebViewDelegate on MacOS X. UI is the prefix for UIKit, which is the iOS equivalent of AppKit. When you see a class whose name begins with UI, you know immediately that you're looking at iOS code.
The class you're probably looking for is WebView. WebView actually uses five separate delegates, so you may need to implement as many as five different protocols: WebUIDelegate, WebDownload, WebFrameLoadDelegate, WebPolicyDelegate, and WebResourceLoadDelegate. (In reality, I don't think you need to do quite that much work. For example, you may not need to implement your own access policy.)
UIWebView is iOS only. You cannot use a UIWebViewDelegate for Mac OSX. If you look at your own code, you are using a WebView, not a UIWebView.
You'll want to look at the WebView class docs

Example for startMonitoringSignificantLocationChanges

I am new to iPhone programming. I am looking for an example or a demo on how to use startMonitoringSignificantLocationChanges method with the CoreLocation Manager.
I am confused by the documentation because, I am not sure if the same delegate method is called as in the case of invoking startUpdatingLocation. (i.e. the delegate locationManager: (CLLocationManager *)manager didUpdateToLocation: (CLLocation *)newLocation fromLocation: (CLLocation *)oldLocation is called)
Any help on this would be appreciated. Also, I am testing it on the simulator by subclassing of CLLocationManager. This subclass provides a simulation of location services when running on the iPhone Simulator. Is there a better way to test this.
I have done a bit of testing with the significant change API. I posted a sample project on GitHub that lets you play with regular and significant location updates.
This question might also shed some light on what happens when you get woken up for a significant change event.
Update
Another thing you should be aware of, there is a bug in CoreLocation in 4.1. Basically if your app is in the background, then it will crash when core location tries to wake you up. It is fixed in 4.2.
There is a great video session on these new iOS 4.0 CoreLocation and MapKit features from WWDC 2010 that should be freely available in iTunes U for all registered iPhone developers.