當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript utils.ios類代碼示例

本文整理匯總了TypeScript中tns-core-modules/utils/utils.ios的典型用法代碼示例。如果您正苦於以下問題:TypeScript ios類的具體用法?TypeScript ios怎麽用?TypeScript ios使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了ios類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: printDeviceInfoIOS

function printDeviceInfoIOS() {
    var device = utils.ios.getter(UIDevice, UIDevice.currentDevice);
    console.log("device.name = " + device.name);                             //device.name = iPhone Simulator
    console.log("device.systemName = " + device.systemName);                 //device.systemName = iPhone OS
    console.log("device.systemVersion = " + device.systemVersion);           //device.systemVersion = 8.1
    console.log("device.model = " + device.model);                           //device.model = iPhone Simulator
    console.log("device.localizedModel = " + device.localizedModel);         //device.localizedModel = iPhone Simulator
    console.log("device.userInterfaceIdiom = " + device.userInterfaceIdiom); //device.userInterfaceIdiom = 0
    console.log("device.batteryLevel = " + device.batteryLevel);             //device.batteryLevel = -1
    var screen = utils.ios.getter(UIScreen, UIScreen.mainScreen);
    console.log("screen = " + screen);
    console.log("screen.nativeBounds = " + screen.nativeBounds.size.width + ", " + screen.nativeBounds.size.height); //screen.nativeBounds = 640, 1136
    console.log("screen.scale = " + screen.scale);                                                                   //screen.scale = 2
    console.log("screen.nativeScale = " + screen.nativeScale);                                                       //screen.nativeScale = 2
}
開發者ID:NathanWalker,項目名稱:NativeScript,代碼行數:15,代碼來源:page5.ts

示例2: waitUntilReady

export function waitUntilReady(isReady: () => boolean, timeoutSec: number = 300, shouldThrow: boolean = true) {
    if (!isReady) {
        return;
    }

    if (Application.ios) {
        // const waitTime = 1 / 10000;
        const timeoutMs = timeoutSec * 1000;
        let totalWaitTime = 0;
        while (true) {
            // const nsDate = <any>NSDate.dateWithTimeIntervalSinceNow(waitTime);
            const begin = time();
            const currentRunLoop = utils.ios.getter(NSRunLoop, NSRunLoop.currentRunLoop);
            currentRunLoop.limitDateForMode(currentRunLoop.currentMode);
            if (isReady()) {
                break;
            }

            totalWaitTime += (time() - begin);
            if (totalWaitTime >= timeoutMs) {
                if (shouldThrow) {
                    throw new Error("waitUntilReady Timeout.");
                } else {
                    break;
                }
            }
        }
    } else if (Application.android) {
        doModalAndroid(isReady, timeoutSec, shouldThrow);
    }
}
開發者ID:sitefinitysteve,項目名稱:NativeScript,代碼行數:31,代碼來源:TKUnit.ts

示例3: Promise

    return new Promise((resolve, reject) => {
      try {
        if (keychainItemServiceName === null) {
          const bundleID = utils.ios.getter(NSBundle, NSBundle.mainBundle).infoDictionary.objectForKey("CFBundleIdentifier");
          keychainItemServiceName = `${bundleID}.TouchID`;
        }

        if (!FingerprintAuth.createKeyChainEntry()) {
          this.verifyFingerprintWithCustomFallback(options).then(resolve, reject);
          return;
        }

        const query = NSMutableDictionary.alloc().init();
        query.setObjectForKey(kSecClassGenericPassword, kSecClass);
        query.setObjectForKey(keychainItemIdentifier, kSecAttrAccount);
        query.setObjectForKey(keychainItemServiceName, kSecAttrService);

        // Note that you can only do this for Touch ID; for Face ID you need to tweak the plist value of NSFaceIDUsageDescription
        query.setObjectForKey(options !== null && options.message || "Scan your finger", kSecUseOperationPrompt);

        // Start the query and the fingerprint scan and/or device passcode validation
        const res = SecItemCopyMatching(query, null);
        if (res === 0) {
          resolve();
        } else {
          reject();
        }

      } catch (ex) {
        console.log(`Error in fingerprint-auth.verifyFingerprint: ${ex}`);
        reject(ex);
      }
    });
開發者ID:EddyVerbruggen,項目名稱:nativescript-touchid,代碼行數:33,代碼來源:fingerprint-auth.ios.ts

示例4: scroll_view_in_full_screen

    private scroll_view_in_full_screen(scrollView: view.View, pageOptions?: helper.PageOptions) {
        let expectedTop = 0;
        if (pageOptions && pageOptions.actionBarFlat) {
            const actionBarHeight = round(dipToDp(scrollView.page.actionBar.nativeViewProtected.frame.size.height));
            const app = iosUtils.getter(UIApplication, UIApplication.sharedApplication);
            const statusBarHeight = round(dipToDp(app.statusBarFrame.size.height));
            expectedTop = actionBarHeight + statusBarHeight;
        }

        const l = left(scrollView);
        const t = top(scrollView);
        const r = right(scrollView);
        const b = bottom(scrollView);
        equal(l, 0, `${scrollView}.left - actual:${l}; expected: ${0}`);
        equal(t, expectedTop, `${scrollView}.top - actual:${t}; expected: ${expectedTop}`);
        equal(r, platform.screen.mainScreen.widthPixels, `${scrollView}.right - actual:${r}; expected: ${platform.screen.mainScreen.widthPixels}`);
        equal(b, platform.screen.mainScreen.heightPixels, `${scrollView}.bottom - actual:${b}; expected: ${platform.screen.mainScreen.heightPixels}`);
    }
開發者ID:vchimev,項目名稱:NativeScript,代碼行數:18,代碼來源:scroll-view-safe-area-tests.ts


注:本文中的tns-core-modules/utils/utils.ios類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。