Is there a (legal) way to capture the ENTIRE screen under iOS?

前端 未结 5 546
悲哀的现实
悲哀的现实 2021-01-19 01:10

I\'ve tried several techniques to capture a screenshot of an app from within that app. None of the techniques appear to capture the status bar -- it ends up being black.

相关标签:
5条回答
  • 2021-01-19 01:44

    Kind of a different approach, but you can also link to pages within the Settings application. You could perhaps link to the primary page and tell the user the changes you require.

    0 讨论(0)
  • 2021-01-19 01:51

    There appears to be no way to do this.

    0 讨论(0)
  • 2021-01-19 01:54

    As an alternative solution, perhaps you could detect the connection type, similar to: https://developer.apple.com/library/ios/#samplecode/Reachability/Introduction/Intro.html . With some additional checking for the device type, you could then warn the user only in the case where they need to act.

    0 讨论(0)
  • 2021-01-19 01:56

    At this point it seems clear that there is no simple way to detect if Airplane Mode is enabled. Although you could probably infer it by looking at low-level network stack info or scraping status bar pixels, either method would be relying on undocumented behavior. It's very possible that on a future release of iOS or a future iOS device, the behavior will change and your code will generate a false positive or false negative.

    (Not to mention that, on future devices, the interference may not even be there.)

    If I were in your shoes, I would:

    1. File a bug to let Apple know you want this feature.

    2. Work the notice into the app, regardless of whether Airplane Mode is enabled. Yes, it might be kind of annoying to the user if it is enabled, but the overall harm is minimal. I would probably make this an alert that pops up only once (storing a key in NSUserDefaults to indicate whether its already been displayed).

    3. If you want to get super-fancy, analyze the recorded audio and, if the buzz is detected, remind the user again to enable Airplane Mode while recording. You could do this in real time or after the clip has been recorded, whatever makes more sense for your app.

    0 讨论(0)
  • 2021-01-19 01:59

    Your actual issue, determining if a network interface is active, can be resolved with BSD networking functions. BEHOLD.

    #include <sys/socket.h>
    #include <ifaddrs.h>
    #include <net/if.h>
    
    BOOL IsNICTurnedOn(const char *nicName) {
        BOOL result = NO;
    
        struct ifaddrs *addrs = NULL;
        if (0 == getifaddrs(&addrs)) {
            for (struct ifaddrs *addr = addrs; addr != NULL; addr = addr->ifa_next) {
                if (0 == strcmp(addr->ifa_name, nicName)) {
                    result = (0 != (addr->ifa_flags & (IFF_UP | IFF_RUNNING)));
                    break;
                }
            }
            freeifaddrs(addrs);
        }
    
        return result;
    }
    

    To use this function:

    BOOL isWWANEnabled = IsNICTurnedOn("pdp_ip0");
    BOOL isWiFiEnabled = IsNICTurnedOn("en0");
    
    0 讨论(0)
提交回复
热议问题