我希望在iPad上允许应用程序轮换,但是希望在iPhone上禁用它,因为它太窄了.
到目前为止,我只看到一个设备或另一个设备上的指令,但不是两个.
有任何想法吗?
根据标题.调用[[UIDevice currentDevice] BeginGeneratingDeviceOrientationNotifications]无效.
DidRotateToInterfaceOrientation等事件工作正常,但我需要能够任意轮询设备方向.
我该如何修复/做到这一点?
长话故事:我在每个选项卡上都有一个带有导航控制器的选项卡应用程序.第一个选项卡的根视图是当方向变为横向时全屏显示的图形; 然而,每当视图出现时都需要检查,因为方向改变可能在其他地方发生,所以我希望在出现此视图时轮询方向状态.
iphone objective-c orientation uidevice interface-orientation
我有一个iPad应用程序,并使用openGL绘制主视图,我想在设备旋转时动画我自己的更改.
请注意,这个应用程序只是偶尔绘制,它不是经常动画.我的场景也是(非常复杂的)2D绘图,而不是3D.我只是希望它在设备方向改变期间简单地围绕显示中心旋转,保持正确的宽高比.
目前我只有以下代码:
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
// nothing yet
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
IMMainView *mv = (IMMainView *)self.view;
[mv createRenderbuffer];
[mv drawView];
}
Run Code Online (Sandbox Code Playgroud)
我只是重新创建OpenGL渲染缓冲区,以便在旋转完成后匹配新的宽度和高度.
默认的iOS行为似乎会旋转视图,但随着宽高比的变化也会奇怪地延伸它.
我可以为我的绘图参数设置动画,以便在过渡期间更好地显示,但我不明白(1)如何停止iOS动画我的图层和(2)如何从这些与iOS匹配的方法调用设置动画循环动画.
例如,在动画期间,实际视图宽度和高度是否逐渐变化?
另外一个可能的问题是何时重新创建渲染缓冲区,因为如果OpenGL缓冲区与iOS视图边界不匹配,则像素纵横比不正确,图形看起来很糟糕.
任何帮助,将不胜感激.
在iPhone模拟器和iPhone 3GS(iOS 6)上,我都无法将方向设置为纵向颠倒.我只有一个ViewController.我在其中添加了此代码:
-(BOOL) shouldAutorotate{
return YES;
}
-(UIInterfaceOrientation) preferredInterfaceOrientationForPresentation{
return UIInterfaceOrientationPortraitUpsideDown;
}
- (NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationPortrait | UIInterfaceOrientationPortraitUpsideDown;
}
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
if (toInterfaceOrientation==UIInterfaceOrientationPortrait || toInterfaceOrientation==UIInterfaceOrientationPortraitUpsideDown) {
return YES;
}
return NO;
}
Run Code Online (Sandbox Code Playgroud)
我还将此添加到AppDelegate.m:
-(NSUInteger) application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
return UIInterfaceOrientationPortrait | UIInterfaceOrientationPortraitUpsideDown;
}
Run Code Online (Sandbox Code Playgroud)
我还检查了plist文件,两个方向都存在.在我的故事板上,在Simulated Metrics Orientation设置为Inferred.我在applicationDidFinishLaunchingWithOptions中什么都不做,除了返回YES.我刚刚在这个ViewController中添加了一个UIImageView.是否有可能使这个方向有效?
接口方向和设备方向有什么区别?两者看起来都一样,但它们之间的实际区别是什么?
我一直在搜索这个问题,找不到任何可以帮助我的东西.
我有一个UIViewController包含在另一个UIViewController中.当父UIViewController旋转时,比如从Portrait到LandscapeLeft,我想让它看起来好像孩子没有旋转.也就是说.无论父母的方向如何,我都希望孩子与天空的方向相同.如果它在Portrait中有一个直立的UIButton,我希望按钮的右侧在UIInterfaceOrientationLandscapeLeft中"向上".
这可能吗?目前,我正在做这样的事情:
-(void) rotate:(UIInterfaceOrientation)fromOrientation: toOr:(UIInterfaceOrientation)toOrientation
{
if(((fromOrientation == UIInterfaceOrientationPortrait) && (toOrientation == UIInterfaceOrientationLandscapeRight))
|| ((fromOrientation == UIInterfaceOrientationPortraitUpsideDown) && (toOrientation == UIInterfaceOrientationLandscapeLeft)))
{
}
if(((fromOrientation == UIInterfaceOrientationLandscapeRight) && (toOrientation == UIInterfaceOrientationPortraitUpsideDown))
|| ((fromOrientation == UIInterfaceOrientationLandscapeLeft) && (toOrientation == UIInterfaceOrientationPortrait)))
{
}
if(((fromOrientation == UIInterfaceOrientationPortrait) && (toOrientation == UIInterfaceOrientationLandscapeLeft))
|| ((fromOrientation == UIInterfaceOrientationPortraitUpsideDown) && (toOrientation == UIInterfaceOrientationLandscapeRight)))
{
}
if(((fromOrientation == UIInterfaceOrientationLandscapeLeft) && (toOrientation == UIInterfaceOrientationPortraitUpsideDown))
|| ((fromOrientation == UIInterfaceOrientationLandscapeRight) && (toOrientation == UIInterfaceOrientationPortrait)))
{
}
if(((fromOrientation == UIInterfaceOrientationPortrait) && (toOrientation …Run Code Online (Sandbox Code Playgroud) iphone uiviewcontroller uiview iphone-sdk-3.0 interface-orientation
ios ×4
iphone ×3
animation ×1
ios6 ×1
objective-c ×1
opengl-es ×1
orientation ×1
portrait ×1
storyboard ×1
uidevice ×1
uiview ×1