本文整理汇总了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
}
示例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);
}
}
示例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);
}
});
示例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}`);
}