我正在做一个基于UISplitViewController的iPad应用程序.当我的应用程序在potrait中启动时,我对toobar按钮有一点问题.不显示显示弹出窗口的按钮.然而,当我将iPad旋转到横向然后再回到肖像时,按钮显示!
看起来在启动时没有调用以下方法(这是我有代码显示按钮):
- (void)splitViewController:(UISplitViewController *)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem *)barButtonItem forPopoverController: (UIPopoverController *)pc
Run Code Online (Sandbox Code Playgroud)
应用程序启动时不会调用此方法,但仅在有旋转时调用.更奇怪的是,我使用Xcode UISplitViewController模板+核心数据制作了一个测试应用程序(类似于我正在使用的应用程序,并且是我用来制作此应用程序的模板).在我没有编写一行代码的测试应用程序上,按钮显示我以纵向模式启动应用程序时,上面的方法也会在启动时调用,而不是我的其他应用程序.有没有人有类似的问题?
最后,从Apple文档中不清楚在首次显示UISplitViewController时是否应该调用此方法:http: //developer.apple.com/library/ios/#documentation/uikit/reference/UISplitViewControllerDelegate_protocol/Reference/的reference.html%23 // apple_ref/DOC/UID/TP40009454
我已设法使用此处的答案将相机预览旋转为肖像:http: //code.google.com/p/zxing/issues/detail?id = 178#c46
然而,预览本身是拉伸/扭曲的 - 高度似乎是拉伸以填充框(但可能是宽度对于屏幕太大而且它被压扁以适应)
有没有办法"包装"内容而不是让它拉伸以适应表面视图?
编辑:我通过改变'CameraConfigurationManager'中的'findBestPreviewSizeValue'方法并反转X和Y点(对于下面指针的sean owen!)进行排序,这里是代码:
private static Point findBestPreviewSizeValue(CharSequence previewSizeValueString,
Point screenResolution) {
int bestX = 0;
int bestY = 0;
int diff = Integer.MAX_VALUE;
for (String previewSize : COMMA_PATTERN.split(previewSizeValueString)) {
previewSize = previewSize.trim();
int dimPosition = previewSize.indexOf('x');
if (dimPosition < 0) {
Log.w(TAG, "Bad preview-size: " + previewSize);
continue;
}
int newX;
int newY;
try {
newY = Integer.parseInt(previewSize.substring(0, dimPosition));
newX = Integer.parseInt(previewSize.substring(dimPosition + 1));
//original:
//newX = Integer.parseInt(previewSize.substring(0, dimPosition));
//newY = …Run Code Online (Sandbox Code Playgroud) 我一直致力于Android项目,旨在兼容Android手机和平板电脑.在平板电脑上,该应用程序运行良好,看起来也很好.然而,在手机上我们已经以编程方式和布局方式遇到问题(使用10.1英寸屏幕比4英寸屏幕容易得多).为解决其中一些问题,我们决定停用屏幕方向,但仅限于手机版本,至少暂时.
问题很简单,我如何停用Android手机的屏幕方向,同时保持Android平板电脑的活动状态?我知道我可以在清单文件中执行此操作,但是,这也将锁定我认为的平板电脑的方向.
我正在使用相机仅显示预览(不拍照或录制视频).
应用程序始终处于纵向模式(禁用横向模式).相机预览总是旋转90度ccw我无法改变它(无论是setDisplayOrientation也不是p.set("orientation", "portrait" )和p.set("rotation", 90) ).
预览总是像这样旋转还是依赖于设备?如果在纵向模式下总是如此,我可以随后旋转图像.
或者有没有办法正确设置相机?我已经阅读了很多有关此问题的帖子,但没有回答对我有用(Galaxy s2,Android v2.3)
当我尝试在控制器上仅允许纵向方向时,我总是收到此错误:Error Domain=UISceneErrorDomain Code=101“视图控制器不支持所请求的方向。请求:landscapeLeft;支持:纵向”UserInfo={NSLocalizedDescription=视图控制器不支持所请求的方向。请求:景观左;支持:纵向}
我称这个方法为:
func updateOrientation(orientation: UIInterfaceOrientationMask) {
if #available(iOS 16, *) {
DispatchQueue.main.async {
let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene
self.setNeedsUpdateOfSupportedInterfaceOrientations()
self.navigationController?.setNeedsUpdateOfSupportedInterfaceOrientations()
windowScene?.requestGeometryUpdate(.iOS(interfaceOrientations: orientation)) { error in
print(error)
print(windowScene?.effectiveGeometry )
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
有人面临同样的问题吗?
当用户从横向旋转到纵向时,我正在遇到一个Android手机带应用程序的奇怪问题,但不是相反.
当屏幕从横向旋转到portait时,内容视口的高度似乎保持在先前的高度 - 但视口的宽度正确调整大小.以下图片试图表明这一点更清晰:
旋转到

我看到了这个问题:Android屏幕方向:风景回到肖像 ......但是虽然接受的答案可能是真的,但我并不完全确定那里有什么要求.
我只有一个带有默认配置的layout/main.xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
我也尝试过一些方向检测脚本,看看是否有帮助 - 我试过了:
var viewPortHeight = $(window).height();
alert (viewPortHeight+" x "+$(window).width());
var headerHeight = $('div[data-role="header"]').height();
var footerHeight = 0;
var contentHeight = viewPortHeight - headerHeight - footerHeight;
// Set all pages with class="page-content" to be at least contentHeight
$('div[class="page-content"]').css({'min-height': contentHeight + 'px'});
Run Code Online (Sandbox Code Playgroud)
并且
var devInfo = new DeviceInformation();
devInfo.setOrientation(0);
time_column_count = Math.floor(viewport.height / 270);
devInfo.setResolution({
height …Run Code Online (Sandbox Code Playgroud) 我有一个 SwiftUI 项目。对于除一种视图之外的所有视图,我想允许纵向和仅纵向模式。对于只有一种视图,我想同时允许纵向和横向。Swift 上有一些资源,但我在 SwiftUI 上找不到任何资源。
有没有人找到一种方法来实现这一点?
我有一个可以纵向或横向启动的应用程序.我想Default.png文件(应用程序启动时出现的启动图像)以正确的方向显示图像,所以我希望我需要使用两个不同的图像(不同的尺寸).但是,我不知道如何让应用程序根据其启动方向选择要使用的图像.这可能吗?有没有办法知道应用程序的启动方向(在显示启动之前),然后选择正确的图像,或者我只需要解决方法是让图像在其中一个方向上侧向旋转或者有一个图像在90度旋转时无法区分?
我正试图在splash-image各种设备上进行手动设置.我这样做是通过检查orientation(触摸设备)或screen width vs. screen height(无触摸)并相应地设置URL.
然后我通过Javascript添加这个CSS规则:
document.styleSheets[3].insertRule('.initHandler:before {
background: url('+x+') no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}', 0)
Run Code Online (Sandbox Code Playgroud)
随着x作为图像取决于方向和屏幕尺寸被加载.
我的问题是这在landscape模式下工作正常,但在我的iPad portrait模式下,加载了正确的图像(根据肖像/风景不同),但它没有扩展到全屏大小.
问题:
我不能background-size在纵横模式下在iOS上使用CSS 吗?
感谢帮助!
编辑:
刚试过我的Android智能手机.那里工作得很好.没有任何意义,为什么它不适用于iPad.
平台: 使用Android SDK 16在Eclipse中开发.
问题: 我有一个VideoView元素应该以480x800(PORTRAIT ORIENTATION)填满整个屏幕,它可以很好地播放,但不会定向到肖像.它坚持横向模式,纵横比倾斜以适应这种方式.
我曾经尝试过什么:
XML:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="480dp"
android:layout_height="800dp"
android:background="#000000"
android:orientation="vertical" >
<VideoView
android:id="@+id/opening_video"
android:layout_width="480dp"
android:layout_alignParentRight="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_alignParentBottom="true"
android:layout_height="800dp"
android:orientation="vertical" />
<ImageButton
android:id="@+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/transparent_button"
android:contentDescription="@string/back_button_desc"
android:background="@android:color/transparent" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
代码:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
setContentView(R.layout.activity_start_screen);
VideoView videoView = (VideoView) findViewById(R.id.opening_video);
Uri pathToVideo = Uri.parse("android.resource://com.example.consumerengage/" + R.raw.opening_tablet);
videoView.setVideoURI(pathToVideo);
videoView.setOnPreparedListener(new OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) …Run Code Online (Sandbox Code Playgroud) portrait ×10
android ×5
orientation ×4
ios ×3
landscape ×2
rotation ×2
background ×1
camera ×1
cordova ×1
css ×1
html5 ×1
ios16 ×1
ipad ×1
launch ×1
stretching ×1
surfaceview ×1
swiftui ×1
tablet ×1
xcode14 ×1
zxing ×1