Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- UIAlertView *alert = [[UIAlertView alloc] initWithTitle:ICLocalizedString(@"LocationServicesPermissionTitle")
- message:ICLocalizedString(@"LocationPermissionGeoFenceMessage")
- delegate:self
- cancelButtonTitle:@"Settings"
- otherButtonTitles:nil];
- [alert show];
- - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
- [alertView dismissWithClickedButtonIndex:buttonIndex animated:YES];
- [[UIApplication sharedApplication] openURL: [NSURL URLWithString: UIApplicationOpenSettingsURLString]];
- }
- UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString( @"Enter your title here", @"" ) message:NSLocalizedString( @"Enter your message here.", @"" ) preferredStyle:UIAlertControllerStyleAlert];
- UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString( @"Cancel", @"" ) style:UIAlertActionStyleCancel handler:nil];
- UIAlertAction *settingsAction = [UIAlertAction actionWithTitle:NSLocalizedString( @"Settings", @"" ) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
- [[UIApplication sharedApplication] openURL:[NSURL URLWithString:
- UIApplicationOpenSettingsURLString]];
- }];
- [alertController addAction:cancelAction];
- [alertController addAction:settingsAction];
- [self presentViewController:alertController animated:YES completion:nil];
- let alertController = UIAlertController(title: NSLocalizedString("Enter your title here", comment: ""), message: NSLocalizedString("Enter your message here.", comment: ""), preferredStyle: .alert)
- let cancelAction = UIAlertAction(title: NSLocalizedString("Cancel", comment: ""), style: .cancel, handler: nil)
- let settingsAction = UIAlertAction(title: NSLocalizedString("Settings", comment: ""), style: .default) { (UIAlertAction) in
- UIApplication.shared.openURL(NSURL(string: UIApplicationOpenSettingsURLString)! as URL)
- }
- alertController.addAction(cancelAction)
- alertController.addAction(settingsAction)
- self.present(alertController, animated: true, completion: nil)
- let alertController = UIAlertController(title: NSLocalizedString("Enter your title here", comment: ""), message: NSLocalizedString("Enter your message here.", comment: ""), preferredStyle: .Alert)
- let cancelAction = UIAlertAction(title: NSLocalizedString("Cancel", comment: ""), style: .Cancel, handler: nil)
- let settingsAction = UIAlertAction(title: NSLocalizedString("Settings", comment: ""), style: .Default) { (UIAlertAction) in
- UIApplication.sharedApplication().openURL(NSURL(string: UIApplicationOpenSettingsURLString)!)
- }
- alertController.addAction(cancelAction)
- alertController.addAction(settingsAction)
- self.presentViewController(alertController, animated: true, completion: nil)
- extension UIAlertController {
- func createSettingsAlertController(title: String, message: String) -> UIAlertController {
- let controller = UIAlertController(title: title, message: message, preferredStyle: .alert)
- let cancelAction = UIAlertAction(title: NSLocalizedString("Cancel", comment:"" ), style: .cancel, handler: nil)
- let settingsAction = UIAlertAction(title: NSLocalizedString("Settings", comment:"" ), style: .default, handler: { action in
- UIApplication.shared.openURL(URL(string: UIApplicationOpenSettingsURLString)!)
- })
- controller.addAction(cancelAction)
- controller.addAction(settingsAction)
- return controller
- }
- }
- extension UIAlertController {
- func createSettingsAlertController(title: String, message: String) -> UIAlertController {
- let alertController = UIAlertController(title: NSLocalizedString("Enter your title here", comment: ""), message: NSLocalizedString("Enter your message here.", comment: ""), preferredStyle: .alert)
- let cancelAction = UIAlertAction(title: NSLocalizedString("Cancel", comment: ""), style: .cancel, handler: nil)
- let settingsAction = UIAlertAction(title: NSLocalizedString("Settings", comment: ""), style: .default) { (UIAlertAction) in
- UIApplication.shared.open(URL(string: UIApplicationOpenSettingsURLString)! as URL, options: [:], completionHandler: nil)
- }
- alertController.addAction(cancelAction)
- alertController.addAction(settingsAction)
- self.present(alertController, animated: true, completion: nil)
- }
- }
Add Comment
Please, Sign In to add comment