我有一个导航控制器,它有几个视图控制器.除了一个只支持横向的特殊视图控制器外,我需要支持所有视图控制器的所有方向.此特殊视图控制器显示在导航堆栈的中间.我做了很多研究,但找不到任何好的解决方案.以下是我阅读和尝试过的链接.
如何从纵向模式自动旋转到横向模式? iPhone - 仅在一个视图控制器上允许横向显示 http://goodliffe.blogspot.com/2009/12/iphone-forcing-uiview-to-reorientate.html
接下来我将尝试替换导航控制器presentModalViewController以显示特殊视图控制器.然后我将在特殊视图控制器内创建一个新的导航视图控制器来推送后续的视图控制器.
如果有人有更好的想法,请告诉我.非常感谢!
更新:我已成功地使用我上述方法:更换pushViewController用presentModalViewController,并创建一个新的导航控制器.
iphone cocoa-touch uinavigationcontroller uiinterfaceorientation ios
我正在尝试检测任何设备方向更改,以便我可以更新视图.
我想更新视图是方向是纵向还是横向,所以我实现了这个方法:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations.
return (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
Run Code Online (Sandbox Code Playgroud)
我知道如果我想更新视图以正确显示当前方向,我将需要实现以下一些方法:
– willRotateToInterfaceOrientation:duration:
– willAnimateRotationToInterfaceOrientation:duration:
– didRotateFromInterfaceOrientation:
– willAnimateFirstHalfOfRotationToInterfaceOrientation:duration:
– didAnimateFirstHalfOfRotationToInterfaceOrientation:
– willAnimateSecondHalfOfRotationFromInterfaceOrientation:duration:
Run Code Online (Sandbox Code Playgroud)
现在,问题是我不明白为什么在旋转模拟器时这些方法都没有被触发.
我试过这段代码:
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
Run Code Online (Sandbox Code Playgroud)
但仍然没有.所以我想知道,模拟器是否会触发旋转通知?如果是的话,我做错了什么?
我正在构建一个ipad应用程序.当应用程序启动时,我以横向右模式显示它.但是一旦应用程序启动,我就会收到此消息
Two-stage rotation animation is deprecated. This application should use the smoother single-stage animation
Run Code Online (Sandbox Code Playgroud)
我在所有课程中都使用了这种方法
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
Run Code Online (Sandbox Code Playgroud)
我还在plist文件中将支持的界面方向(iPad)设置为横向.如何解决此警告消息?
我知道如何允许/禁止使用方向旋转
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
但是,我现在遇到的问题是手机可能处于纵向(或倒置),并且在某些时候我想要旋转屏幕,就像用户旋转到横向一样.此时,我不想让自动旋转工作了.我想强制界面方向保持在横向.有没有办法做到这一点?我可能想出一个关闭自动旋转的黑客攻击,但是首先迫使旋转我不知道该怎么办.
这是我正在尝试做的事情:
该应用程序旋转到任何和所有方向.一切正常.
发生事件.
现在,自动旋转仅适用于landscapeleft和landscaperight.此外,如果用户处于纵向或纵向倒置,我以编程方式旋转到landscaperight以将用户锁定到该方向.
只是为了让事情变得棘手,我想UIAlertView在强制轮换之前弹出一个(我知道该怎么做),让用户知道发生了什么,并且我想在alertView后面进行屏幕旋转而不是alertView.这甚至可能吗?
谢谢.
我已经为iOS 4.2做了应用程序,我正在使用XCode 4.3.3进行开发并使用iPhone 5.1模拟器进行测试,一切正常.最近我决定测试应用程序在iOS 6.0上运行的方式.在尝试这个时,我面临两个问题:
因此,我使用XCode 4.5打开应用程序并在iPhone 6.0 Simulator上运行它.我有启动应用程序的问题.XCode只是说:完成在iPhone 6.0模拟器上运行,停止按钮是灰色的(就像应用程序没有运行)和iPhone模拟器只显示黑屏,没有任何反应.我要CMD + Q吧.这对我来说是个巨大的问题,因为我设法在很多失败之后成功地随机运行应用程序.
最终,有时,应用程序运行没有问题,我看到模拟器正在运行我的应用程序.应用程序仅以横向模式进行.但是当模拟器运行应用程序时,它将保持纵向模式并显示为纵向模式下的横向屏幕设计的应用程序.我已将支持接口方向设置为两个横向变体,而在Application-Info.plist中也列出了这两个横向方向.
有谁知道发生了什么和可能的解决方案?
提前谢谢了.
[编辑#1:添加了所有输出控制台消息]
控制台消息(对于现在一直存在的问题1)说:
error: failed to attach to process ID 0
Run Code Online (Sandbox Code Playgroud)
[编辑#2:解决第一个问题的小进展]
好的,奇怪的事情正在发生.为了消除编辑#1中的错误,我做的第一件事是:
在XCode中转到:产品 - >编辑方案 - >运行[AppName] .app - > Debugger并将其从LLDB更改为GDB
在此之后,编辑#1的错误消失了,但是出现了新问题.现在我运行应用程序后,我在XCode中获取状态消息:附加到[AppName]并且XCode停留在该操作上.
如果有人给我一个答案,我想说我尝试了以下列表中的所有内容:
以及各种这些动作排列.简单地说,我总是看到这个问题.发生在我身上的最好的事情是在这个组合中:
只打开XCode而不打开项目 - >转到窗口 - >管理器 - > [ProjectName]并完全删除它 - >退出XCode - >打开iPhone模拟器并重置设置 - >退出iPhone模拟器 - >重启Mac …
我有
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
Run Code Online (Sandbox Code Playgroud)
在info.plist中并进行搜索并设置shouldAutorotateToInterfaceOrientation要返回的每个实例YES.但在iPhone上它表现得好像不支持颠倒.UpsideUp肖像作品,风景作品,上下颠倒显示风景.为什么?
iPad适用于所有方向.他们分享.xibs
UPDATE
我已经补充说了
- (BOOL)shouldAutorotate {
return YES;
}
- (NSUInteger)supportedInterfaceOrientations {
return UIInterfaceOrientationMaskAll;
}
Run Code Online (Sandbox Code Playgroud)
在每一个现有的实例之后shouldAutorotateToInterfaceOrientation,仍然没有爱.
我的目标是iOS 4.3,但我的模拟器和物理设备运行iOS 6
我正在创建一个仅在横向模式下工作的应用程序.
在注册期间,我想打开相机或呈现UIImagePickerController,但应用程序崩溃时出现以下错误:
*** Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and [PUUIAlbumListViewController shouldAutorotate] is returning YES'
如何在风景中呈现图像选择器或相机?
objective-c uiimagepickercontroller uiimage uiinterfaceorientation ios
我已经实现了下面的代码来改变AVCaptureVideoSession基于以下内容的方向UIInterfaceOrientation:
- (AVCaptureVideoOrientation)interfaceOrientationToVideoOrientation:(UIInterfaceOrientation)orientation {
switch (orientation) {
case UIInterfaceOrientationPortrait:
return AVCaptureVideoOrientationPortrait;
case UIInterfaceOrientationPortraitUpsideDown:
return AVCaptureVideoOrientationPortraitUpsideDown;
case UIInterfaceOrientationLandscapeLeft:
return AVCaptureVideoOrientationLandscapeLeft;
case UIInterfaceOrientationLandscapeRight:
return AVCaptureVideoOrientationLandscapeRight;
default:
break;
}
NSLog(@"Warning - Didn't recognise interface orientation (%ld)",(long)orientation);
return AVCaptureVideoOrientationPortrait;
}
Run Code Online (Sandbox Code Playgroud)
这段代码几乎完美无缺.但是,出现的一个问题是,如果您快速将iOS设备旋转180度,相机将显示为颠倒.
以下是旋转前相机视图的样子:

这是旋转后的样子:

另外,这是我的实现viewDidLayoutSubviews:
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
previewLayer.frame = self.view.bounds;
self.view.translatesAutoresizingMaskIntoConstraints = NO;
previewLayer.videoGravity = AVLayerVideoGravityResizeAspectFill;
[self.view.layer addSublayer:previewLayer];
if (previewLayer.connection.supportsVideoOrientation) {
previewLayer.connection.videoOrientation = [self interfaceOrientationToVideoOrientation:[UIApplication sharedApplication].statusBarOrientation];
}
}
Run Code Online (Sandbox Code Playgroud)
这个180度旋转发生时有没有人知道为什么摄像机视图会颠倒?
objective-c uiinterfaceorientation ios avcapturesession viewdidlayoutsubviews
我的应用程序中的所有视图控制器仅在纵向工作,除了可以是纵向或横向的视图控制器.
我有一些使用场景如下:
执行这些操作后,应用程序将保持横向方向,并且不会自动将其更改为纵向.
我使用supportedInterfaceOrientations控制视图控制器方向(我使用的是iOS 6.0).我做错了什么?当用户按下后退按钮时应用程序自动将方向更改为允许时,如何才能获得正确的行为?谢谢你的答案!
我在这里遇到一个奇怪的问题.
出于某种原因,我在视图控制器中使用方向更改时禁用动画[UIView setAnimationsEnabled:NO];
但是当存在警报视图时,如果我更改了方向,那么它会产生奇怪的结果.
附加的屏幕截图是我将方向更改为横向时.

请注意:我使用的是标准版UIAlertView,它是默认覆盖图,它在警报视图出现时显示,此处不涉及自定义.
根据文档
If you disable animations, code inside subsequent animation blocks is still executed but no animations actually occur. Thus, any changes you make inside an animation block are reflected immediately instead of being animated.
所以它不应该影响默认覆盖的大小调整. Is it a restriction in disabling animation !??
我不明白为什么我会这样.有谁可以帮助解决这个问题.
ios ×9
iphone ×4
objective-c ×4
cocoa-touch ×1
ios5.1 ×1
ios6 ×1
ipad ×1
uialertview ×1
uiimage ×1