- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个正常工作的页面 curl 。问题是 iPad 的旋转。该应用程序仅横向运行,支持 l 左和 l 右。如果 iPad 是“横向右”,则 curl 会出现在右下角。如果我旋转 iPad, View 会按预期旋转,但现在当我尝试时, curl 发生在左上角。我添加了一个通知,告诉我它何时旋转并尝试更改动画子类型但没有骰子。
-(IBAction)curlViewUp
{
uiv_help.alpha = 1.0;
[UIView animateWithDuration:1.0
animations:^{
CATransition *animation = [CATransition animation];
[animation setDelegate:self];
[animation setDuration:0.7];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
animation.type = @"pageCurl";
animation.subtype = curlDirection;
animation.fillMode = kCAFillModeForwards;
animation.endProgress = 0.20;
[animation setRemovedOnCompletion:NO];
[self.view.layer addAnimation:animation forKey:@"pageCurlAnimation"];
[self.view addSubview:uiv_help];
;}
];
}
-(IBAction)curlViewDown
{
uiv_help.alpha = 0.0;
[UIView animateWithDuration:1.0
animations:^{
CATransition *animation = [CATransition animation];
[animation setDelegate:self];
[animation setDuration:0.7];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]];
animation.type = @"pageUnCurl";
animation.subtype = curlDirection;
animation.fillMode = kCAFillModeForwards;
animation.startProgress = 0.80;
[animation setRemovedOnCompletion:YES];
[self.view.layer addAnimation:animation forKey:@"pageUnCurlAnimation"];
//[self.view removeFromSuperview];
[uiv_help removeFromSuperview];
;}
];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft | interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
-(void)checkRotation:(NSNotification*)notification
{
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
if(orientation == UIInterfaceOrientationLandscapeLeft)
{
NSLog(@"UIInterfaceOrientationLandscapeLeft");
curlDirection = @"fromRight";
} else if (orientation == UIInterfaceOrientationLandscapeRight) {
NSLog(@"UIInterfaceOrientationLandscapeRight");
curlDirection = @"fromRight";
}
}
最佳答案
您的 pagecurl 没有随设备旋转。
这是因为它的 View 不随设备旋转而旋转..
这是是因为它的 View 是 View 层次结构中最顶层的 View 。
我在任何地方都找不到这方面的文档(其他人可以挖掘出来吗?),但是 View 层次结构中最外面的 View 不会旋转。我想那是因为正是这个 View 负责旋转其他所有内容(或者更确切地说,这个 View 应用了某种旋转变换)。
验证起来很简单,只需记录 View 的框架和边界并观察旋转时发生的情况。
这里是肖像模式。我已经设置了一个包含在 self.view 中的 subview ,具有相同的尺寸。
self.view frame {{0, 20}, {768, 1004}}
self.view bounds {{0, 0}, {768, 1004}}
self.view center {384, 522}
--------
self.subview frame {{0, 0}, {768, 1004}}
self.subview bounds {{0, 0}, {768, 1004}}
self.subview center {384, 502}
现在让我们旋转到横向
self.view frame {{20, 0}, {748, 1024}}
self.view bounds {{0, 0}, {1024, 748}}
self.view center {394, 512}
--------
self.subview frame {{0, 0}, {1024, 748}}
self.subview bounds {{0, 0}, {1024, 748}}
self.subview center {512, 374}
您会看到内部 subview 正确报告宽度为 1024 和高度为 748 像素。但是外面的景色变得很奇怪。它的框架报告宽度为 748,高度为 1024,就好像它仍然是纵向的(加上状态栏 20px)。但它的界限告诉我们它是风景。
我们显然不想依赖报告这种奇怪结果的 View 的几何属性。我想这与 Apple 的警告有关,即如果 View 的框架受到除恒等变换之外的任何变换,则不应引用 View 的框架。
解决方案是将您的 pagecurling View 嵌入到另一个最外层的 View 中。创建一个新 View ,将其命名为 self.subview(或其他名称),并将其作为 self.view 的唯一 subview 添加到您的 View 层次结构中。将其调整为与 self.view 相同的矩形。在 self.subview 而不是 self.view 上操作。
改变这一行:
[self.view.layer addAnimation:animation forKey:@"pageCurlAnimation"];
到
[self.subview.layer addAnimation:animation forKey:@"pageCurlAnimation"];
并更改这一行:
[self.view.layer addAnimation:animation forKey:@"pageUnCurlAnimation"];
到:
[self.subview.layer addAnimation:animation forKey:@"pageUnCurlAnimation"];
然后您的 curls 将按预期运行,因为您将它们应用到按预期旋转的 View 。
您可以在不更改代码的情况下获得相同的结果,但将您的 viewController 嵌入到 UINavigationViewController 中。在那种情况下,NavViewController 的 View 是不旋转的最外面的 View 。所以你的 self.view 会旋转。
更新
UIWindow* mWindow = [[UIApplication sharedApplication] keyWindow];
UIView *topView = [[mWindow subviews] lastObject];
NSLog("%@",topView);
topView <UILayoutContainerView: 0x71eb450;
frame = (0 0; 748 1024);
transform = [0, 1, -1, 0, 0, 0];
autoresize = W+H; gestureRecognizers = <NSArray: 0x71f8a30>;
layer = <CALayer: 0x71eb540>>
注意变换。
关于page-curl - CATransition 不考虑 iPad 上的方向变化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13367022/
我正在使用 MapBox 绘制兴趣点,这些兴趣点是通过基于 Rails 构建的用户生成表单提交的。当前,用户输入一个地址,然后该地址通过 gem(地理编码器)计算出 Lat 和 Lng。从那里我通过
我正在纵向平板电脑上开发应用程序。 但是,当平板电脑转到横向模式时,应用程序也会转动,并且所有对齐方式都将被取消。那么有什么方法可以将我的 WPF 应用程序锁定到一个方向? 谢谢! 最佳答案 我必须同
我在我的应用程序中的 mkmapview 上显示了两点之间的路线,但我想显示这两点的方向。点的纬度和经度存储在 NSArray 中。 最佳答案 这可能为时已晚,您可能已经解决了它,但这是我已经测试过并
我正在处理一个小型 Unity3D 项目,我需要从另一个工具导入一些数据。该工具通过两个向量为我提供了对象方向,我需要将其移植到 Unity。 例如,我有这两个向量; x = Vector( 0.70
有没有办法以编程方式设置 UIActionSheet 的方向?我的 iPhone 方向是纵向,但 UIActionSheet 需要是横向。这可以吗? 编辑: 所以我的问题是我不想将 rootviewc
如何在 Python 中根据 2 个 GPS 坐标计算速度、距离和方向(度)?每个点都有纬度、经度和时间。 我在这篇文章中找到了半正矢距离计算: Calculate distance between
需要一个代码来更改 div 的属性,具体取决于 iPhone 设备的位置。在这段代码工作之前现在停止这样做了吗? @media all and (orientation:portrait) { .
在“View Did Load”中,我试图确定 View 的大小,以便我可以适本地调整 subview 的大小。我希望它始终围绕屏幕的长度和宽度拉伸(stretch),而不管方向如何。 quest *
如何根据对象的方向移动对象?我的意思是,我有一个处于某个位置的立方体,我想绕 Y 轴旋转并根据它们的方向移动。然后再次移动和旋转以改变方向。像这样的事情: 最佳答案 在 JS 中你可以尝试这样的事情:
我目前有一个处于横向模式的 SurfaceView。 目前我正在尝试使用添加操作栏/菜单栏 /*Action Bar */ //this.setRequestedOrientation(Activit
我正在使用 cocos2d,我想播放电影。为此,我创建了 MPMoviePlayerViewController 并将其作为 [[CCDirector sharedDirector] openGLVi
我在 cocos2d 中创建了一个游戏,因为我想使用我找到的一些 UIKit 元素 kobold2d。 我移植了游戏,但问题是我的 iPhone 刺激器旋转了, 但不是显示的节点。 必须使用: bac
我可以在 iOS 中的 UITabBarController 中更改方向吗?我有这样的东西: UITableViewController-> Team Tab -> UINavigationContr
我有 UINavigationController 和几个 View Controller 。这是他们的名单:主->相册->图片 现在,在第一个和第二个(主要和专辑)中,我希望 UINavigatio
人们普遍认为,在过去几年中,标准显示器的最佳网站宽度已从 800 像素增加到 1024+ 像素(网站通常为 960 像素宽),但随着移动设备的兴起,哪些分辨率被认为是“关键”迎合? 例如,this
我正在做一个 GTK+ 项目,我需要一个像这样的垂直 GtkLevelBar: 但我不知道如何从默认的水平 GtkLevelBar 翻转它: 这是我的 GtkLevelBar 代码。 GtkWidge
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我的 collectionView 以横向模式显示 20 个项目。在纵向模式下,我只想展示 8 个可重复使用的项目。我怎样才能做到这一点? collectionView 何时在数据源上调用 colle
可以在 list 文件中设置 Activity 的方向。 但是否也可以通过代码来实现?如果是,怎么办? 谢谢! 最佳答案 setRequestedOrientation(ActivityInfo.SC
我希望在纬度、经度和用户当前位置之间集成方向。我希望通过点击按钮将用户定向到已安装的 Google map /其他应用程序并显示方向。 我搜索了 SO 和谷歌,但找不到好的来源,因此我发布了这个问题。
我是一名优秀的程序员,十分优秀!