Tag: 旋转

即使是风景,iPad模式视图控制器仍然以纵向行事

我在横向模式下呈现ModalViewController有一些困难。 基本上,它显示在适当的界面方向,只有当设备被持有在横向模式,但视图控制器的行为,就像是在肖像模式旋转。 我正在呈现这样的模式 – (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; // Override point for customization after application launch. self.viewController = [[ViewController alloc] initWithNibName:@"ViewController" bundle:nil]; UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:self.viewController]; self.window.rootViewController = navController; [self.window makeKeyAndVisible]; LoginViewController *lvc = [[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:[NSBundle mainBundle]]; [self.window.rootViewController presentModalViewController:lvc animated:NO]; return YES; } […]

IOS:旋转uiimageview

在我的应用程序中,我有一个imageview,它的名字是箭头,我用这种方法旋转180度: arrow.transform = CGAffineTransformMakeRotation(M_PI); 它工作正常,但现在我想这个imageview返回原来的位置; 我应该设置什么价值来获得它?

强制设备旋转时+ attemptRotationToDeviceOrientation失败

根据这里的UIViewController文档, https://developer.apple.com/library/ios/documentation/uikit/reference/UIViewController_Class/Reference/Reference.html#//apple_ref/occ/clm/UIViewController/attemptRotationToDeviceOrientation 使用[UIViewController attemptRotationToDeviceOrientation]强制系统尝试将界面旋转到新的方向。 我试图强制从纵向到横向的界面旋转: 在尝试旋转之前设置forceLandscape标志 调用[UIViewController attemptRotationToDeviceOrientation] 在我的视图控制器中实现-supportedInterfaceOrientations并检查标志以更改支持的方向,例如 这迫使-supportedInterfaceOrientations再次被调用,看起来像 – (NSUInteger)supportedInterfaceOrientations { return self.forceLandscape ? UIInterfaceOrientationMaskLandscapeLeft : UIInterfaceOrientationMaskPortrait; } 即使正在调用-supportedInterfaceOrientations并返回新的方向,接口也不会旋转。 我已经确认该项目允许所有的方向,并且这个视图控制器是窗口的根视图控制器。 有没有其他人遇到这个问题,并find一个解决scheme? 我知道所有的窍门,以解决这个问题(提交和解雇模态等),但我希望有一个干净的解决scheme,如果可能的话。 我已经在iOS 6和7上validation了这个问题。 以下是完整的代码重现: @interface ALTViewController () @property (nonatomic, assign) BOOL forceLandscape; @end @implementation ALTViewController – (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { self.forceLandscape = NO; […]

拖动+旋转使用UIPanGestureRecognizer触摸下车轨道

我正在使用UIPanGestureRecognizer进行拖动和旋转计算。 旋转angular度是正确的,拖动位置几乎是正确的。 问题是,当你走在箱子的中心需要根据angular度进行调整,我不知道如何。 我已经包含了旋转过程中180度旋转的图像,但手指在哪里。 我只是不知道如何调整,使块适当地留在你的手指。 inheritance人一个video只是为了澄清,因为这是奇怪的行为。 http://tinypic.com/r/mhx6a1/5 编辑:这是一个真实的世界video应该发生什么。 问题是,在iPadvideo中,您的手指正在移动,在真实世界的任何地方,您的手指会粘在物品移动的特定位置。 math需要的是调整你的触摸位置的angular度与实际中心的差异。 我只是无法弄清楚math。 http://tinypic.com/r/4vptnk/5 非常感谢! – (void)handlePan:(UIPanGestureRecognizer *)gesture { if (gesture.state == UIGestureRecognizerStateBegan) { // set original center so we know where to put it back if we have to. originalCenter = dragView.center; } else if (gesture.state == UIGestureRecognizerStateChanged) { [dragView setCenter:CGPointMake( originalCenter.x + [gesture translationInView:self.view].x , […]

仅在一个ViewController中旋转

我试图旋转一个视图,而所有其他视图(5)固定为肖像。 原因在于,在这种观点中,我希望用户观看他以前保存的照片。 我想这是可能的,但到目前为止我无法弄清楚如何实现这一目标。 任何人都可以帮助或给我一个提示? 我在iOS8上运行Swift编程

iOS 8 – 应用程序不能正常旋转

我有一个最初为iOS 7.1开发的应用程序,现在我正在通过Xcode 6.1在iPad上进行testing。 在运行7.1或7.1模拟器的iPad上运行时,应用程序按预期运行。 在8.1 iPad或8.1模拟器上,似乎旋转处理不当。 我看到顶部的状态栏旋转,但应用程序本身不会改变。 我知道这是相关的旋转方法在​​iOS 8被弃用。我的问题是…现在是什么? 我还没有find任何文档提供了一个简明的答案,如何处理旋转使用新的iOS 8机制。 有没有办法像我在iOS 7中处理它们一样正常处理iOS 8中的旋转? 我甚至没有看到旧的旋转方法被调用,所以看起来好像这不仅仅是一种典型的“贬低”。 似乎他们已经完全取消了对这些方法的呼叫。 任何帮助或build议?

UIImageView上的iOS CAKeyframeAnimation rotationMode

我正在试验沿着贝塞尔path移动的UIImageView对象位置的关键帧animation。 此图显示了animation之前的初始状态。 蓝线是path – 最初是直线向上移动,浅绿色的框是最初的边界框或图像,深绿色的“鬼”是我正在移动的图像: 当我将rotationMode设置为nil下启动animation时,图像始终保持与预期一样的方向。 但是,当我使用rotationMode设置为kCAAnimationRotateAuto来kCAAnimationRotateAutoanimation时,图像将立即逆时针旋转90度,并始终保持此方向通过path。 当它到达path的末端时,它会以正确的方向重新绘制(它实际上显示了我重新定位到最终位置的UIImageView) 我天真地期望rotationMode将图像定位到path的正切,而不是正常,特别是当Apple文档为CAKeyframeAnimation rotationMode状态 确定沿pathanimation的对象是否旋转以匹配path切线。 那么这里的解决scheme是什么? 我是否需要将图像顺时针旋转90度? 还是有什么我失踪? 谢谢你的帮助。 编辑3月2日 我在pathanimation之前使用仿射旋转添加了一个旋转步骤,如下所示: theImage.transform = CGAffineTransformRotate(theImage.transform,90.0*M_PI/180); 然后在pathanimation之后,重置旋转: theImage.transform = CGAffineTransformIdentity; 这使得图像以预期的方式跟随path。 不过,我现在遇到了图像闪烁的另一个问题。 我已经在这个SO问题中寻找闪烁问题的解决scheme: animation结束时,iOS CAKeyFrameAnimation缩放闪烁 所以现在我不知道我是做得更好还是更糟! 3月12日编辑 虽然迦勒指出是的,我不得不预先旋转我的形象,罗布提供了一个很好的代码包,几乎完全解决了我的问题。 Rob唯一没有做的就是补偿我的资产是以垂直方向而不是水平方向绘制的,因此在做animation之前还需要将它们预先旋转90度。 但是,嘿,唯一公平的是我必须做一些工作才能使事情顺利进行。 所以我对Rob的解决scheme进行了一些细微的修改以适应我的要求: 当我添加UIView时,我预先旋转它来抵消通过设置rotationMode添加的固有rotationMode : theImage.transform = CGAffineTransformMakeRotation(90 * M_PI / 180.0); 我需要在animation结束时保持这个旋转,所以我没有在完成块被定义之后用新的比例因子对视图的变换进行爆破,而是基于当前的变换构build比例: theImage.transform = CGAffineTransformScale(theImage.transform,scaleFactor,scaleFactor); 这就是我所需要做的就是让自己的形象像我期望的那样走上去! 3月22日编辑 我刚刚上传到GitHub上的一个演示项目,展示了一个沿着贝塞尔path移动的对象。 代码可以在PathMove中find 我还在我的博客中写过关于在iOS中沿着贝塞尔path移动对象的问题

iOS8 – 防止呈现viewController旋转

我们有一个带有tableView的MainViewController,它提供了一个新的modalViewController。 MainViewController仅限于肖像,并且modalViewController可以旋转。 问题是在iOS8中,当modalViewController旋转时,在MainViewcontroller中iOS8中的旋转callback方法被称为- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator 因此,UITableView正在重新获得它的数据,这是我们不想要的行为。 我们可以防止iOS 8的这个function,而不是旋转呈现UIViewController?

旋转后的UIView坐标交换,但UIWindow的不是?

使用Xcode 4.2.1 iPad iOS 5.0.1,创build一个新的“Single View”iPad项目。 在控制器中添加: – (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES; } – (void) dumpView: (UIView *) view { CGRect frame = view.frame ; CGRect bounds = view.bounds ; CGPoint center = view.center ; NSLog(@"view [%@]:%d frame=%@ bounds=%@ center=%@" , NSStringFromClass(view.class) , [view hash] , NSStringFromCGRect(frame) , NSStringFromCGRect(bounds) , NSStringFromCGPoint(center)) ; } – (void) […]

事件willAnimateRotationToInterfaceOrientation不调用

我有几个UIViewController在应用程序上。 但是只有其中的一个会调用willAnimateRotationToInterfaceOrientation事件。 如何使willAnimateRotationToInterfaceOrientation适用于所有可见视图?