zoukankan      html  css  js  c++  java
  • iOS判断程序在前台还是后台

    [UIApplication sharedApplication].applicationState will return current state, check it possible values and don’t create unnecessary flags when you can use system features.

    Values you may want to consider:

    • UIApplicationStateActive(前台)
    • UIApplicationStateInactive(收到通知)
    • UIApplicationStateBackground(后台)

    e.g.

    +(BOOL) runningInBackground
    {
        UIApplicationState state = [UIApplication sharedApplication].applicationState;
        BOOL result = (state == UIApplicationStateBackground);
    
        return result;
    }
    
    +(BOOL) runningInForeground
    {
        UIApplicationState state = [UIApplication sharedApplication].applicationState;
        BOOL result = (state == UIApplicationStateActive);
    
        return result;
    }
  • 相关阅读:
    ASP.NET 篇
    .NET Core 篇
    JS-CSS篇
    IIS使用篇
    WebService篇
    电脑使用篇
    数据库使用篇
    正则表达式篇
    Linux学习篇
    Leetcode 198. 打家劫舍 dp
  • 原文地址:https://www.cnblogs.com/tangyuanby2/p/6924399.html
Copyright © 2011-2022 走看看