我只需要设置android设备智能手机肖像吗? window.isTablet 仅查找手机或平板电脑,因此我需要设置屏幕锁定方向并编写代码。
答案 0 :(得分:2)
使用我们修复的Cordova Screen Orientation Plugin。
在app.js
document.addEventListener("deviceready", function() {
if (window.innerHeight <= 736 || window.innerWidth <= 736) {
screen.orientation.lock('portrait');
} else {
screen.orientation.unlock('portrait');
}
});
window.addEventListener("orientationchange", function() {
if (window.innerHeight <= 736 || window.innerWidth <= 736) {
screen.orientation.lock('portrait');
} else {
screen.orientation.unlock('portrait');
}
});
答案 1 :(得分:0)
如果您想仅允许potrait
模式 ,请添加 -
<platform name="android">
<preference name="Orientation" value="portrait" />
<allow-intent href="market:*" />
</platform>
项目文件夹中<widget>
内的config.xml
标记。
考虑到此Cordova Device插件,您可能无法找到Tablet or Mobile version
。
您可以获得以下properties -
- device.cordova //在设备上运行的Cordova版本。
- device.model //设备型号或产品的名称
- device.platform //设备的操作系统名称
- device.uuid
- device.version
- device.manufacturer //设备的制造商。
- device.isVirtual //设备是虚拟的(模拟的)或真实的
- device.serial
答案 2 :(得分:0)
使用以下代码
def optimistic_restore(session, save_file, flags):
if flags.checkpoint_exclude_scopes is not None:
exclusions = [scope.strip() for scope in flags.checkpoint_exclude_scopes.split(',')]
reader = tf.train.NewCheckpointReader(save_file)
saved_shapes = reader.get_variable_to_shape_map()
print ('saved_shapes %d' % len(saved_shapes))
var_names = sorted([(var.name, var.name.split(':')[0]) for var in tf.global_variables()
if var.name.split(':')[0] in saved_shapes])
var_names_to_be_initialized = sorted([(var.name, var.name.split(':')[0]) for var in tf.global_variables()
if var.name.split(':')[0] not in saved_shapes])
print('var_names %d' % len(var_names))
print('var_names_to_be_initialized %d' % len(var_names_to_be_initialized))
restore_vars = []
name2var = dict(zip(map(lambda x: x.name.split(':')[0], tf.global_variables()), tf.global_variables()))
print('name2var %d' % len(name2var))
with tf.variable_scope('', reuse=True):
variables_to_init = []
for var_name, saved_var_name in var_names:
curr_var = name2var[saved_var_name]
var_shape = curr_var.get_shape().as_list()
if var_shape == saved_shapes[saved_var_name]:
excluded = False
for exclusion in exclusions:
if saved_var_name.startswith(exclusion):
variables_to_init.append(curr_var)
excluded = True
break
if not excluded:
restore_vars.append(curr_var)
else:
variables2_to_init.append(curr_var)
for var_name, saved_var_name in var_names_to_be_initialized:
curr_var = name2var[saved_var_name]
variables2_to_init.append(curr_var)
print('variables2_to_init : %d ' % len(variables_to_init))
print('global_variables: %d ' % len(tf.global_variables()))
print('restore_vars: %d ' % len(restore_vars))
saver = tf.train.Saver(restore_vars)
saver.restore(session, save_file)
session.run(tf.variables_initializer(variables_to_init))