Showing cellular data is turned off alert

吃可爱长大的小学妹 提交于 2019-12-03 16:56:32

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!