我在这里面临一个奇怪的问题。
由于某种原因,我在视图控制器中使用方向更改期间禁用动画[UIView setAnimationsEnabled:NO];
但是,当存在警报视图并且如果我更改方向时,它会给出奇怪的结果。
所附的屏幕截图是当我将方向更改为横向时的。
请注意:我正在使用标准UIAlertView
这是当警报视图存在时显示的默认覆盖图,并且此处不涉及自定义。
根据文档 http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIView_Class/UIView/UIView.html
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 !??
我不明白为什么我会变成这样。
有人可以帮忙解决这个问题吗?
当你设置[UIView setAnimationsEnabled:NO];
, UIAlertView
没有调整它的覆盖视图的大小(我认为这是一个错误)。
您可以选择在屏幕上显示警报视图时限制方向,如下所示。
创建一个BOOL
.h 文件中的变量。
BOOL shouldRotate;
初始化它YES
in viewDidload
.
每当你表现出警觉的时候shouldRotate = NO;
并实施UIAlertView
委托如下:
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
shouldRotate = YES;
}
希望能帮到你。
Edit:因为您想要没有动画和带有警报视图的旋转
这实际上是一个黑客但有效,
alert
is an UIAlertView
的对象在 .h 文件中声明。
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation{
if (UIInterfaceOrientationPortrait == UIInterfaceOrientationIsPortrait(fromInterfaceOrientation)) {
UIImageView *imgView = (UIImageView *)[alert.superview.subviews objectAtIndex:0];
imgView.frame = CGRectMake(0.0, 0.0, 480.0, 320.0);
}
else{
UIImageView *imgView = (UIImageView *)[alert.superview.subviews objectAtIndex:0];
imgView.frame = CGRectMake(0.0, 0.0, 320.0, 480.0);
}
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)