将我的应用程序更新为iOS6标准时,纵向/横向消失了.当我使用Xcode 3构建时,Ir工作得很好.但是现在使用最新的Xcode和最新的SDK,旋转消失了,它始终处于纵向模式.无论我在"支持的界面方向"中加入什么.我以前用来获得旋转的代码似乎根本没有效果.我有这些台词.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
switch (toInterfaceOrientation) {
case UIInterfaceOrientationPortrait:
case UIInterfaceOrientationLandscapeLeft:
case UIInterfaceOrientationLandscapeRight:
return YES;
default:
return NO;
}
}
Run Code Online (Sandbox Code Playgroud)
我如何更改以及如何更改以使其再次运行?
iOS 7
如果我的应用程序最初支持两种方向,如何强制纵向方向?
我有一个简单的问题:我希望UINavigationBar
在我的设备处于纵向状态时找出景观的高度.这是可能的,如果是的话,怎么样?
一些背景:
UINavigationBar *navBar = [[UINavigationBar alloc] initWithFrame:CGRectZero];
[navBar sizeToFit];
NSLog(@"navBar: %@", NSStringFromCGRect(navBar.frame));
Run Code Online (Sandbox Code Playgroud)
这将返回正确的高度为当前设备的方向,例如44
.这意味着,UINavigationBar
的sizeToFit
方法必须以某种方式看待当前设备的方向.有没有什么方法可以找到景观中的高度而不去景观?
uinavigationbar orientation uiinterfaceorientation ios landscape-portrait
在设备处于纵向模式时,是否可以在横向捕获视频?
实际上我需要的是以纵向捕捉,但宽度>高度,我不希望用户旋转设备,但我确实想要捕捉像横向模式更广泛的图片.
只是将预览图层框架更改为宽(宽度>高度)当然不够.
我尝试更改预览图层的视频方向,但这将旋转图片,这不是我想要的.
previewLayer.connection.videoOrientation = .landscapeRight
Run Code Online (Sandbox Code Playgroud)
这有什么意义吗?
我在浏览器中嵌入了Youtube视频,这是所有肖像应用程序的一部分.当您启动YouTube视频时,它将在MPAVController中播放并允许在Landscape中旋转.这对我来说不是问题,但问题是如果视频是横向的,我按"OK"关闭视频; 我返回浏览器,但iPhone状态栏现在停留在横向模式,在应用程序顶部留下一个空白区域,以及状态栏覆盖我的应用程序的右侧或左侧部分,具体取决于旋转方向.
包含UIWebView的视图控制器被纵向锁定:
- (BOOL) shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationMaskPortrait;
}
Run Code Online (Sandbox Code Playgroud)
请注意,使用6.0之前的SDK进行编译时,不会出现此问题.
有类似问题的人有解决方案吗?
youtube iphone uiinterfaceorientation landscape-portrait ios6
我有一个通用的横向模式应用程序.SKStoreProductViewController在iPad上运行良好.但在iphone ios上崩溃7.甚至我将SKStoreProductViewController设置为在iPhone上的肖像上显示.
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation {
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
NSLog(@"iphone portrait");
return UIInterfaceOrientationPortrait;
}
else
return [super preferredInterfaceOrientationForPresentation];
}
Run Code Online (Sandbox Code Playgroud)
SKStoreProductViewController在iOS 7的iphone上显示,但是当我旋转手机时,它会崩溃.我收到错误消息说:
*由于未捕获的异常'UIApplicationInvalidInterfaceOrientation'终止应用程序,原因:'支持的方向与应用程序没有共同的方向,并且shouldAutorotate返回YES'
谁知道如何解决这个问题?
谢谢
大小等级:
紧凑宽度任何高度适合所有紧凑宽度布局(除iPhone 6以外的所有手机)
紧凑的宽度常规高度适用于potrait中的所有iphone
横向所有iphone的任何宽度紧凑高度(iphone 6 plus除外)
常规宽度紧凑高度(适用于iPhone 6 plus)iphone 6 plus横向
现在我有了标签,我改变了iPhone 6和iPhone 6的字体大小,例如"紧凑宽度任何高度","12"和"紧凑宽度常规高度",它的"15"纵向.所有iPhone的纵向尺寸均为15.
但是当我将"任何宽度紧凑高度"的字体大小更改为"12"并将"常规宽度紧凑高度"更改为"15"时,它可以正常工作.
我的问题是我应该如何为肖像做同样的事情?
我正在开发具有内嵌视频播放器的应用程序。我需要重现 Youtube 的全屏行为。
当用户横向旋转设备时,我通过 onConfigurationChanged 捕获它并进行相应的布局修改。
但是,我也有一个按钮来设置全屏。我需要这个按钮去 landscpe(ergo,全屏),但不要通过传感器锁定方向变化。
这是我目前在 onConfigurationChanged 上所做的:
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if (this.isLandscape(newConfig.orientation)){
this.goToFullScreenMode();
}else{
this.goToInlineMode();
}
}
Run Code Online (Sandbox Code Playgroud)
这是我在按钮中所做的但失败了,因为它将活动锁定在横向:
this.getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
Run Code Online (Sandbox Code Playgroud)
我需要的是进入横向模式,但允许用户使用传感器更改回纵向模式,就像 Youtube 那样。
我可以通过锁定横向直到设备水平(通过直接从传感器读取)然后再次解锁方向来做到这一点。我不认为这是最“正确”的做法。
我创建了一款在桌面模式下运行良好的游戏.但是当我在移动设备上运行时,它只能以横向模式运行.如何在纵向和横向模式下使游戏成功运作?
我有一个自定义相机,可以在人像模式下拍照。
我的问题是,如果我尝试以横向方式拍摄照片并保存,那么图片仍会以纵向模式保存。
我有这个功能来设置预览层:
static func setupPreviewLayer(view: UIView) {
cameraPreviewLayer = AVCaptureVideoPreviewLayer(session: captureSession)
cameraPreviewLayer?.videoGravity = AVLayerVideoGravity.resizeAspectFill
switch UIDevice.current.orientation {
case .portrait:
cameraPreviewLayer?.connection?.videoOrientation =
AVCaptureVideoOrientation.portrait
case .portraitUpsideDown:
cameraPreviewLayer?.connection?.videoOrientation =
AVCaptureVideoOrientation.portraitUpsideDown
case .landscapeLeft:
cameraPreviewLayer?.connection?.videoOrientation =
AVCaptureVideoOrientation.landscapeLeft
case .landscapeRight:
cameraPreviewLayer?.connection?.videoOrientation =
AVCaptureVideoOrientation.landscapeRight
default:
cameraPreviewLayer?.connection?.videoOrientation =
AVCaptureVideoOrientation.portrait
}
cameraPreviewLayer?.frame = view.frame
view.layer.insertSublayer(cameraPreviewLayer!, at: 0)
}
Run Code Online (Sandbox Code Playgroud)
我称之为 viewWillAppear (我认为这不是正确的做法)。
然后我拍了张照片:
@IBAction func takePhotoBtnPressed(_ sender: Any) {
let settings = AVCapturePhotoSettings()
useFlash(settings: settings)
settings.isAutoStillImageStabilizationEnabled = true
CustomCamera.photoOutput?.capturePhoto(with: settings, delegate: self)
}
Run Code Online (Sandbox Code Playgroud)
并使用此扩展名:
extension FishCameraVC: AVCapturePhotoCaptureDelegate {
func …
Run Code Online (Sandbox Code Playgroud) ios ×4
iphone ×3
android ×2
avfoundation ×2
ios6 ×2
ios7 ×2
objective-c ×2
ios8 ×1
ipad ×1
java ×1
libgdx ×1
orientation ×1
size-classes ×1
swift ×1
xcode ×1
youtube ×1