简体   繁体   中英

Showing cellular data is turned off alert

How can I show this alert view? I know that I need check connection with reachability, but how do I show this alert with settings and ok button? I need it for iOS 6.

在此输入图像描述

Unfortunately in iOS 5.1 and later you can't open settings app from your app.

If you are using lesser version the following will work.

Create the Alert view like:

UIAlertView *cellularData = [[UIAlertView alloc] initWithTitle: @"Cellular Data is Turned Off" message:@"Turn on ellular data or use Wi-Fi to access data"  delegate:self cancelButtonTitle:@"OK" otherButtonTitles:@"Settings", nil];
[cellularData show];

Implement the clickedButtonAtIndex like:

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
   if(buttonIndex == 1)
   {
      [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"prefs:root=General&path=Network"]]
   }
}

It'll open the settings app from your application.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM