Guest User

Untitled

a guest
Jan 18th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.50 KB | None | 0 0
  1. UIAlertView *alert = [[UIAlertView alloc] initWithTitle:ICLocalizedString(@"LocationServicesPermissionTitle")
  2. message:ICLocalizedString(@"LocationPermissionGeoFenceMessage")
  3. delegate:self
  4. cancelButtonTitle:@"Settings"
  5. otherButtonTitles:nil];
  6. [alert show];
  7.  
  8. - (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
  9. [alertView dismissWithClickedButtonIndex:buttonIndex animated:YES];
  10. [[UIApplication sharedApplication] openURL: [NSURL URLWithString: UIApplicationOpenSettingsURLString]];
  11. }
  12.  
  13. UIAlertController *alertController = [UIAlertController alertControllerWithTitle:NSLocalizedString( @"Enter your title here", @"" ) message:NSLocalizedString( @"Enter your message here.", @"" ) preferredStyle:UIAlertControllerStyleAlert];
  14.  
  15. UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:NSLocalizedString( @"Cancel", @"" ) style:UIAlertActionStyleCancel handler:nil];
  16. UIAlertAction *settingsAction = [UIAlertAction actionWithTitle:NSLocalizedString( @"Settings", @"" ) style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
  17. [[UIApplication sharedApplication] openURL:[NSURL URLWithString:
  18. UIApplicationOpenSettingsURLString]];
  19. }];
  20.  
  21. [alertController addAction:cancelAction];
  22. [alertController addAction:settingsAction];
  23.  
  24. [self presentViewController:alertController animated:YES completion:nil];
  25.  
  26. let alertController = UIAlertController(title: NSLocalizedString("Enter your title here", comment: ""), message: NSLocalizedString("Enter your message here.", comment: ""), preferredStyle: .alert)
  27.  
  28. let cancelAction = UIAlertAction(title: NSLocalizedString("Cancel", comment: ""), style: .cancel, handler: nil)
  29. let settingsAction = UIAlertAction(title: NSLocalizedString("Settings", comment: ""), style: .default) { (UIAlertAction) in
  30. UIApplication.shared.openURL(NSURL(string: UIApplicationOpenSettingsURLString)! as URL)
  31. }
  32.  
  33. alertController.addAction(cancelAction)
  34. alertController.addAction(settingsAction)
  35. self.present(alertController, animated: true, completion: nil)
  36.  
  37. let alertController = UIAlertController(title: NSLocalizedString("Enter your title here", comment: ""), message: NSLocalizedString("Enter your message here.", comment: ""), preferredStyle: .Alert)
  38.  
  39. let cancelAction = UIAlertAction(title: NSLocalizedString("Cancel", comment: ""), style: .Cancel, handler: nil)
  40. let settingsAction = UIAlertAction(title: NSLocalizedString("Settings", comment: ""), style: .Default) { (UIAlertAction) in
  41. UIApplication.sharedApplication().openURL(NSURL(string: UIApplicationOpenSettingsURLString)!)
  42. }
  43.  
  44. alertController.addAction(cancelAction)
  45. alertController.addAction(settingsAction)
  46. self.presentViewController(alertController, animated: true, completion: nil)
  47.  
  48. extension UIAlertController {
  49. func createSettingsAlertController(title: String, message: String) -> UIAlertController {
  50. let controller = UIAlertController(title: title, message: message, preferredStyle: .alert)
  51.  
  52. let cancelAction = UIAlertAction(title: NSLocalizedString("Cancel", comment:"" ), style: .cancel, handler: nil)
  53. let settingsAction = UIAlertAction(title: NSLocalizedString("Settings", comment:"" ), style: .default, handler: { action in
  54. UIApplication.shared.openURL(URL(string: UIApplicationOpenSettingsURLString)!)
  55. })
  56. controller.addAction(cancelAction)
  57. controller.addAction(settingsAction)
  58.  
  59. return controller
  60. }
  61. }
  62.  
  63. extension UIAlertController {
  64.  
  65. func createSettingsAlertController(title: String, message: String) -> UIAlertController {
  66.  
  67. let alertController = UIAlertController(title: NSLocalizedString("Enter your title here", comment: ""), message: NSLocalizedString("Enter your message here.", comment: ""), preferredStyle: .alert)
  68.  
  69. let cancelAction = UIAlertAction(title: NSLocalizedString("Cancel", comment: ""), style: .cancel, handler: nil)
  70. let settingsAction = UIAlertAction(title: NSLocalizedString("Settings", comment: ""), style: .default) { (UIAlertAction) in
  71. UIApplication.shared.open(URL(string: UIApplicationOpenSettingsURLString)! as URL, options: [:], completionHandler: nil)
  72. }
  73.  
  74. alertController.addAction(cancelAction)
  75. alertController.addAction(settingsAction)
  76. self.present(alertController, animated: true, completion: nil)
  77.  
  78. }
  79. }
Add Comment
Please, Sign In to add comment